Asp.net只允许通过路由访问?

时间:2012-07-14 12:51:41

标签: asp.net url-routing

我使用URL重写来制作用户友好的URL。因此,www.mysite.som/search正由www.mysite/search.aspx正确处理。但还有一件事我想要。我想阻止直接访问我的网页search.aspx。因此,如果有人输入www.mysite.com/search.aspx,则应将其重定向到www.mysite.com/search

我尝试了什么?

<rewrite>
<rule name="Redirect to friendly" stopProcessing="true">
  <match url="^(.*)\.aspx$" />
  <action type="Redirect" url="{R:1}" />
</rule>
</rewrite>

但它不起作用。

0 个答案:

没有答案