开发者

Problem redirecting to 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜