我在 Windows 7 RC 上使用 IIS 7.5。我使用 IIS Url Rewrite 模块来重写 URL。
一切似乎都工作正常,直到我通过单击按钮执行回发。然后它将查询字符串参数附加到我重写的 URL 中,如下所示:
重写的 URL,如浏览器中显示的那样:http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike
如果没有 URL 重写,则 URL 为:
当我单击按钮执行回发时,URL 更改为:
当 URL 被重写时,所有查询字符串参数都会加倍 - 所以当我想通过这样做来获取当前语言时:
Request.QueryString["lang"]
我得到的值是“en,en”。
还有其他人有这些问题吗?
更新:重写 Web.Config 中的规则
<rule name="RedirectProductPageUrls" stopProcessing="true">
<match url="^product\.aspx$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_METHOD}" negate="true" pattern="^POST$" />
<add input="{QUERY_STRING}" pattern="^lang=([^=&]+)&id=([^=&]+)&title=([^=&]+)$" />
</conditions>
<action type="Redirect" url="{C:1}/products/{C:2}/{C:3}" appendQueryString="false" redirectType="Permanent" />
</rule>
<rule name="RewriteProductPageUrls" stopProcessing="true">
<match url="^([^/]+)/product/([^/]+)/([^/]+)/?$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="product.aspx?lang={R:1}&id={R:2}&title={R:3}" />
</rule>
我能够通过添加来解决这个问题
Form.Action = Request.RawUrl;
到 Page_Load 事件。我能够保留appendQueryString =“TRUE”,到目前为止它工作正常。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)