我在Windows 7 RC上使用IIS 7.5。我使用IIS Url Rewrite模块来重写URL。具有URL重写模块的IIS 7.5在Postback上加倍QueryString Params
似乎一切正常,直到我通过单击按钮执行回发。然后,追加查询字符串PARAMS我重写URL,就像这样:
重写后的URL,因为它出现在浏览器: http://localhost/en/product/1239/Gary+Fisher+Hkek+Mountain+Bike
没有URL重写URL是:
http://localhost/product.aspx?lang=en&id=1239&title=Gary+Fisher+Hkek+Mountain+Bike
当我点击一个按钮来执行回发时,URL更改为:
而当URL重写,所有的查询字符串PARAMS增加一倍 - 所以,当我想这样做是为了获得当前语言:
Request.QueryString["lang"]
我回来的值是“恩,恩”。
其他人有这些问题吗?
UPDATE:从程序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>
你可以发布你的重写规则吗?只需发布web.config中的任何内容: ... –
2009-07-21 20:10:35
已更新,其中包含重写规则和产品页面的重定向规则。 – MartinHN 2009-07-24 10:53:27