gpt4 book ai didi

c# - Response.Redirect 停止使用 IIS 7 重写规则

转载 作者:太空宇宙 更新时间:2023-11-03 16:17:19 24 4
gpt4 key购买 nike

我最近将网站迁移到运行 Windows Server 2008 的新服务器,随后托管在 IIS 7 上。

我已经为页面实现了 URL 重写规则。这是一个例子。

               <rule name="RewriteUserFriendlyURL58" stopProcessing="true">
<match url="^(shop)/(item)/([^/]+)/([^/]+)/([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="shopitem.aspx?{R:1}&amp;{R:2}&amp;id={R:3}&amp;cat={R:4}&amp;title={R:5}" />
</rule>

URL 应如下所示。 http://www.website.com/shop/item/10/products/table/

除非我单击按钮并运行此事件,否则页面工作正常。

protected void btnAddToBasket_Click(object sender, EventArgs e)
{
Response.Redirect("~/shoppingbasket/");
}

重定向的结果似乎是重定向自身,然后 URL 更改为:http://www.website.com/shop/item/10/products/table/?shop&item&id=10&cat=products&title=table

谁能指出我正确的方向?我对此进行了几次搜索,但似乎找不到任何内容。

最佳答案

这看起来实际上是“天哪,我错过了!”我们都有的问题类型 :)。

<action type="Rewrite" url="shopitem.aspx?{R:1}&amp;{R:2}&amp;id={R:3}&amp;cat={R:4}&amp;title={R:5}" />

您专门调用重写。将其更改为重定向,我相信它会按照您的预期执行。

值得注意的是,在 IIS 中结合使用事件中的重定向和重写可能会发生冲突。您可能想要选择其中之一。

关于c# - Response.Redirect 停止使用 IIS 7 重写规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15450005/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com