removing aspx extension
-
Hi, I want to remove the extension of my asp.net webpages(I have a webapplication). I've read some guidelines about the issue but I've found some simple ways to do it. I've tried adding the following lines to my web.config file:
I have also tried to add this function to Application_BeginRequest in my global.asax file:
string curruntpath = Request.Path.ToLower();
curruntpath = curruntpath.Trim();
if (curruntpath.EndsWith(".aspx"))
{
string finalurl = curruntpath.Substring(curruntpath.Length - 5, 5);
HttpContext.Current.RewritePath(finalurl);
}In the first case, when I type "www.site.com/page" I'm being redirected to "www.site.com/page.aspx"(which is my wanted page), but when I type "www.site.com/page.aspx" I want the shown URL to be "www.site.com/page", and it doesn't happen. In the second attempt I just can't get any page when typing "www.site.com/page.aspx". What should I do in order to solve it?