【问题标题】:Problem redirecting to another page重定向到另一个页面的问题
【发布时间】:2011-03-04 18:43:55
【问题描述】:

我在尝试重定向其他页面时收到“Internet Explorer 无法显示该网页”错误。

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

谢谢 BB

【问题讨论】:

  • 请提供更多信息。这个重定向发生在哪里?它被重定向到的页面上发生了什么?是否仅在 IE 中发生此错误?是编译器错误还是运行时错误?
  • 我有一个名为 Claims 的网站应用程序,我正在尝试从 Default.aspx 重定向到 AnotherForm.aspx。

标签: c# redirect response


【解决方案1】:

Response.Redirect() 使用的ResolveURL() 不能很好地与 UrlEncode 配合使用,试试这个:

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

同时检查这个相关的 SO 答案:Response.Redirect using ~ Path

【讨论】:

    【解决方案2】:

    你打错了HttpUtility.UrlEncode

    你应该只Encode参数值。
    通过 Encodeing 整个 URL,您正在转义 / 字符,从而弄乱您的 URL。

    【讨论】:

      猜你喜欢
      • 2019-09-01
      • 2021-06-27
      • 1970-01-01
      • 2017-08-10
      • 2019-03-16
      • 2018-06-19
      • 2016-12-14
      • 1970-01-01
      相关资源
      最近更新 更多