How to pass '#' in query string

坚强是说给别人听的谎言 提交于 2019-12-18 08:56:08

问题


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


回答1:


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




回答2:


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




回答3:


URL-encode the sharp character: %23.




回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/11297504/how-to-pass-in-query-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!