Asp.net allow access only through routes?

妖精的绣舞 提交于 2019-12-23 03:25:11

问题


I am using URL rewrite to make user-friendly URL's. So www.mysite.som/search is being handled by www.mysite/search.aspx correctly. But there is one more thing I want. I want to prevent direct access to my page search.aspx. So, if someone enters www.mysite.com/search.aspx, he should be redirected to www.mysite.com/search instead.

What have I tried?

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

But its not working.

来源:https://stackoverflow.com/questions/11483899/asp-net-allow-access-only-through-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!