How do you hide file extension in URL using ASP.NET WebForms?

Inbound URLs are easy - simply grab a tool like URL Rewriter, create a rule to map incoming requests that do not have .aspx to include the aspx in the processing of the request and you are done.

The problem, however, is outbound URLs. Your site/app generates URLs everywhere and every one of those contains a link to something.aspx and which is the very format you are trying to get away from. You can either rewrite your entire app to not include the .aspx or you can put something in the pipeline to filter those out of the pages before they are sent to the user.

Again, URL Rewriter can do this, but it takes a while to get the rules right. Another fairly common approach is to simply write your own httpModule and do the processing yourself.

Bear in mind that any utility that rewrites outbound page content may cause problems with server-side caching.

Tags:

Asp.Net

Url