开发者

stop Response.Redirect from encoding

The URL string generated after this response.redirect is causing us a headache. It is replacing the characters with url percent encoding characters and adding in extra file directories.

Response.Redirect("TestingReport.aspx?id=" + Request.QueryString("id") + "&Test_Type_ID=" + Request.QueryString("Test_Type_ID") + "&TType=" + Request.QueryString("TType"))

https://subdomain.domain.com/User%20Portal/Testing/%2fUser%2520Portal%2fTesting%2fTestingReport.aspx%3fid%3d8444%26Test_Type_ID%3d2%26TType%3dCore%20Mandatory%202

Why is it changing ? and = to the percent codes? I don't under开发者_JAVA技巧stand why it is appending User Portal/Testing twice either.

Thanks


It's called URLEncoding. Checkout this online utility to decode the string you have. In .NET, you can use System.Web.HttpUtility to encode/decode.


The entire URL gets URL ecoded, which is probably because you are not URL encoding the values that you put in the string. URL encode the values properly, and it should work:

Response.Redirect(
  "TestingReport.aspx?id=" + Server.UrlEncode(Request.QueryString("id")) +
  "&Test_Type_ID=" + Server.UrlEncode(Request.QueryString("Test_Type_ID")) +
  "&TType=" + Server.UrlEncode(Request.QueryString("TType"))
)


Might want to build your query string separately from the Redirect method line, URL encode those values and then HTML encode the URL passed to Response.Redirect

Sample shown from MSDN website. I suspect that your concatenation operations are somehow causing the framework to URL encode the entire thing, rather than just the values.

<% 

dim qs

qs = Server.URLEncode(Request.Querystring) 

Response.Redirect "newpage.asp?" + Server.HTMLEncode(qs) 
%>

http://msdn.microsoft.com/en-us/library/ms524309.aspx


Check out this post. Basically .Net is trying to sanitize the URL for you and messing up. The solution is to manually encode it.


Make sure that there in no empty space in your URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜