How to hide asp url in url bar?

寵の児 提交于 2019-12-14 03:12:56

问题


How to hide aspx extension in asp.net project?

Ex -

http://mcs.com/Profile.aspx
http://mcs.com/Profile
or
http://mcs.com/

回答1:


you need to use URL-Rewriting for this...

URL Rewriting in ASP.NET




回答2:


If you are using ASP.NET 4, you can use URL Routing (not rewriting). you can see this post: http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx




回答3:


quick search pulled up a rule you can run

   <rule name="">
      <!--Removes the .aspx extension for all pages.-->
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="{R:1}.aspx" />
    </rule> 


来源:https://stackoverflow.com/questions/11288051/how-to-hide-asp-url-in-url-bar

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