Response.Redirect 导致相对路径格式错误

发布于 2024-10-10 01:43:53 字数 897 浏览 0 评论 0原文

我在让 Response.Redirect 在 SSL 后面的 IIS 7 上运行的 ASP.NET Web 表单网站上正常工作时遇到问题。重定向路径附加到我当前的路径中,我无法找出导致此问题的配置。

我的执行代码是:

string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + '/';
Response.Redirect(Server.UrlEncode(baseUrl + "Default.aspx"), true);

我的 web.config 的相关部分是:

<system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true" />

  and

<httpRuntime useFullyQualifiedRedirectUrl="true" requestPathInvalidCharacters="" />

从目录 Ui/Forms 执行,我得到这个 https://mysite.edu/Ui/Forms/https%3a%2f%2fmysite.edu%2fUi%2fForms%2fhttps%253a%2f%2fmysite.edu%2fDefaul.aspx

任何配置指针或链接都是有帮助。谢谢。

I have a problem with getting Response.Redirect to work properly on my ASP.NET web forms site running on IIS 7 behind SSL. The redirect path is appended to my current path, and I cannot find out which configuration is causing this.

My execution code is :

string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + '/';
Response.Redirect(Server.UrlEncode(baseUrl + "Default.aspx"), true);

Relevant parts of my web.config are :

<system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true" />

  and

<httpRuntime useFullyQualifiedRedirectUrl="true" requestPathInvalidCharacters="" />

Executed from the directory Ui/Forms, I get this
https://mysite.edu/Ui/Forms/https%3a%2f%2fmysite.edu%2fUi%2fForms%2fhttps%253a%2f%2fmysite.edu%2fDefaul.aspx

Any configuration pointers or links are helpful. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

煮茶煮酒煮时光 2024-10-17 01:43:53

我找到了自己的答案,却忘了提及这个难题的关键部分。触发上面代码的按钮位于 UpdatePanel 中,我忘记向该按钮的更新面板添加 PostBackTrigger。然后 Response.Redirect 就可以工作了。

<Triggers>
    <asp:PostBackTrigger ControlID="btnSubmit" />
</Triggers>

I found my own answer and forgot to mention a key piece of the puzzle. The button firing the code above was in an UpdatePanel, and I forgot to add a PostBackTrigger to the update panel for that button. Response.Redirect then works.

<Triggers>
    <asp:PostBackTrigger ControlID="btnSubmit" />
</Triggers>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文