Mar*_*nHN 8 asp.net url-rewriting iis-7.5
我在Windows 7 RC上使用IIS 7.5.我使用IIS Url Rewrite模块重写URL.
一切似乎工作正常,直到我通过单击按钮执行回发.然后它将查询字符串params附加到我重写的URL,如下所示:
重写的URL,因为它出现在浏览器中: http:// localhost/en/product/1239/Gary + Fisher + Hkek + Mountain + Bike
没有URL重写,URL是:
HTTP://localhost/product.aspx LANG = EN&ID = 1239&标题=加里·费舍尔+ + + Hkek山地自行车+
当我单击按钮执行回发时,URL将更改为:
HTTP://本地主机/ EN /产品/ 1239 /加里·费舍尔+ + + Hkek山地自行车+ LANG = EN&ID = 1239&标题=加里·费舍尔+ + + Hkek山地自行车+
当重写URL时,所有查询字符串参数都加倍 - 所以当我想通过这样做获取当前语言时:
Request.QueryString["lang"]
Run Code Online (Sandbox Code Playgroud)
我得到的价值是"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>
Run Code Online (Sandbox Code Playgroud)
Rya*_*sen 12
我能够通过添加来解决这个问题
Form.Action = Request.RawUrl;
Run Code Online (Sandbox Code Playgroud)
到Page_Load事件.我能够离开appendQueryString ="TRUE",到目前为止它正常工作.
| 归档时间: |
|
| 查看次数: |
9381 次 |
| 最近记录: |