How to pass '#' in query string

后端 未结 5 1336
抹茶落季
抹茶落季 2020-12-21 01:12

I want to pass \'#\' to the query string like ?page.aspx?someParam=1234#5.

相关标签:
5条回答
  • 2020-12-21 01:14

    URL-encode the sharp character: %23.

    0 讨论(0)
  • 2020-12-21 01:25

    try using escape(url parameter value) method in url instead of only parameter value

    0 讨论(0)
  • 2020-12-21 01:26

    Please use Server.UrlEncode on your querystring that will parse the '#' for you

    0 讨论(0)
  • 2020-12-21 01:28

    Try using %23. This is the url encoded value for #.

    0 讨论(0)
  • 2020-12-21 01:30

    The best way to pass #, & and other special characters without causing problems in asp.net query string is to use Server.UrlEncode()
    See the following example.

      private void btnSubmit_Click(object sender, System.EventArgs e)
      {
         Response.Redirect("page.Aspx?"+"someParam="+Server.UrlEncode("1234#5")); 
      } 
    


    or use %23 replacing # but I think the more suitable way is using Server.UrlEncode() so you can use other special characters without any problem.

    0 讨论(0)
提交回复
热议问题