【发布时间】:2012-06-01 14:48:15
【问题描述】:
我想在成功注册/登录后在url中输入用户的用户名,像这样
http://myweb.com/username/255
http://myweb.com/username/settings
我正在使用 ASP.Net Rewrite 模块,这是我目前使用的生成 http://myweb.com/home/255 的重写规则之一:
<rule name="HomeRewrite" stopProcessing="true">
<match url="^home$"/>
<conditions>
<add input="{URL}" pattern="\.axd$" negate="true"/>
</conditions>
<action type="Rewrite" url="/home.aspx"/>
</rule>
我试着像这样改变自己:
<rule name="HomeRewrite" stopProcessing="true">
<match url="^{R:1}/home$"/>
<conditions>
<add input="{URL}" pattern="\.axd$" negate="true"/>
</conditions>
<action type="Rewrite" url="/home.aspx"/>
</rule>
但它不起作用,我知道我做错了。那么在这方面有什么帮助吗?
【问题讨论】:
-
为什么不使用页面路由?我有一些页面路由代码将用户名添加到路由数据中。还是您希望浏览器地址栏中的 URL 发生变化?
标签: asp.net url-rewriting