开发者

Problem redirecting to another page

开发者 https://www.devze.com 2023-02-15 01:35 出处:网络
I am getting \"Internet Explorer cannot display the webpage\" error while trying to redirect ot another page.

I am getting "Internet Explorer cannot display the webpage" error while trying to redirect ot another page.

string targetURL = "~/AnotherFo开发者_StackOverflow中文版rm.aspx?Xresult=" + HttpUtility.UrlEncode(res);
    Response.Redirect(targetURL);

Thanks BB


ResolveURL() which is used by Response.Redirect(), doesn't work nicely with UrlEncode, try this:

string targetURL = "~/AnotherForm.aspx?Xresult=" +  HttpUtility.UrlEncode(res);

Also check this related SO answer: Response.Redirect using ~ Path


You're miscalling HttpUtility.UrlEncode.

You should only Encode the parameter value.
By Encodeing the entire URL, you are escaping the / characters, messing up your URL.

0

精彩评论

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