IIS 7.5 URL重写模块双打查询字符串PARAMS上回发 [英] IIS 7.5 with URL Rewrite Module Doubles QueryString Params on Postback
问题描述
我使用的Windows 7 RC IIS 7.5。我使用IIS URL重写模块来重写URL。
一切似乎都做工精细,直到我通过点击按钮执行回发。然后,追加查询字符串PARAMS我重写URL,如下所示:
重写后的URL,因为它出现在浏览器:
<一href=\"http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike\">http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike
如果没有URL重写URL是:
<一个href=\"http://localhost/product.aspx?lang=en&id=1239&title=Gary+Fisher+Hkek+Mountain+Bike\">http://localhost/product.aspx?lang=en&id=1239&title=Gary+Fisher+Hkek+Mountain+Bike
当我点击一个按钮来执行回发的网址更改为:
<一个href=\"http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike?lang=en&id=1239&title=Gary+Fisher+Hkek+Mountain+Bike\">http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike?lang=en&id=1239&title=Gary+Fisher+Hkek+Mountain+Bike
和当URL重写,所有的查询字符串PARAMS一倍 - 所以,当我想这样做是为了获得当前的语言:
的Request.QueryString [郎]
我回来的值为恩,恩。
是其他任何人有这样的问题?
更新:从Web.Config中重写规则
&LT;规则名称=RedirectProductPageUrlsstopProcessing =真&GT;
&LT;匹配URL =^产品\\ $的.aspx/&GT;
&LT;条件logicalGrouping =MatchAll&GT;
&LT;添加输入={} REQUEST_METHOD否定=真模式=^ $ POST/&GT;
&LT;添加输入={QUERY_STRING}模式=^ LANG =([^ =&放大器;放大器;] +)和放大器;放大器; ID =([^ =&放大器;放大器;] +)和放大器;放大器;标题= ([^ =&放大器;放大器;] +)$/&GT;
&所述; /条件&gt;
&lt;作用TYPE =重定向URL ={C:1} /产品/ {C:2} / {C:3}appendQueryString =假redirectType =永久/&GT;
&LT; /规则&GT;
&LT;规则名称=RewriteProductPageUrlsstopProcessing =真&GT;
&LT;匹配URL =?^([^ /] +)/产品/([^ /] +)/([^ /] +)/ $/&GT;
&LT;条件logicalGrouping =MatchAll&GT;
&LT;添加输入={} REQUEST_FILENAME使用MatchType =ISFILE否定=TRUE/&GT;
&LT;添加输入={} REQUEST_FILENAME使用MatchType =IsDirectory否定=TRUE/&GT;
&所述; /条件&gt;
&lt;作用TYPE =重写URL =product.aspx LANG = {R:1}&放大器;放大器;编号= {R:2}?&放大器;放大器;标题= {R:3}/&GT;
&LT; /规则&GT;
在appendQueryString =false属性添加到重写规则的动作元素以及
希望这有助于。
I'm using IIS 7.5 on Windows 7 RC. I use the IIS Url Rewrite module to rewrite URLs.
Everything seems to work fine, until I perform a postback by clicking a button. It then appends the querystring params to my rewritten URL, like this:
Rewritten URL, as it appears in the browser: http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike
Without URL rewriting the URL is:
http://localhost/product.aspx?lang=en&id=1239&title=Gary+Fisher+Hkek+Mountain+Bike
When I click a button to perform a postback, the URL changes to this:
And when the URL is rewritten, all querystring params are doubled - so when I want to get the current language by doing this:
Request.QueryString["lang"]
The value I get back is "en,en".
Is anyone else having those problems?
UPDATE: Rewrite rules from 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>
Add the appendQueryString="false" attribute to the action element of the rewrite rule as well.
Hope this helps.
这篇关于IIS 7.5 URL重写模块双打查询字符串PARAMS上回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!