This question already has an answer here:
I am using ASP.NET Web Forms.
I have a situation where an ASPX page needs to come up without the .aspx
extension.
Following is an example (not real site):
www.abc.com/firstpage
The page is actually called firstpage.aspx
, but I wonder if I could make it work without the .aspx
.
The reason why this is important is because an email got sent out
with www.abc.com/firstpage
, and now I need to figure out how to
make it programatically go to www.abc.com/firstpage.aspx
.
Search for "extensionless URLS" and "URL Rewriting".
There is a good article here.
Quick and dirty: create firstpage folder, create index.html file in it. Place this inside:
This will fix your problem without messing around with URL rewrites, etc.
If you are using .net 4.5 you can use Asp.net Friendly URLS: http://aspnetfriendlyurls.codeplex.com/
Use a URL rewrite rule (i.e. to rewrite
www.abc.com/firstpage
towww.abc.com/firstpage.aspx
). IIS and third-party rewrite modules (e.g. ones compatible with Apache syntax) can do this.If you are using ASP.NET 4.0 or later, then you can use ASP.NET routing in WebForms.
Read Walkthrough: Using ASP.NET Routing in a Web Forms Application.