Reputation: 25
I had developed a Web application in Asp.net. When am using the Application over IIS, the file extension as.aspx is visible. Is it possible to hide it (or) rename it....Thankx in advance.
Upvotes: 0
Views: 217
Reputation: 1269
For .NET Framework 3.5 or earlier, you can accomplish this using routing. Try the following solution:
Upvotes: 0
Reputation: 1269
For .NET framework 4.0+, try the following rule in web.config
(inside <system.webServer>
):
The first will redirect URLs using the old format, to remove the .aspx
extensions. You should of course update your links as well - eventually you won't need this.
The second rule rewrites URLs internally to add .aspx
behind the scenes.
<rewrite>
<rules>
<rule name="RedirectOldFormat" enabled="true" stopProcessing="true">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="InternallyAddAspx" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
</rules>
</rewrite>
Upvotes: 1