Link to home
Start Free TrialLog in
Avatar of K_CH_Krishna
K_CH_KrishnaFlag for India

asked on

How to hide .aspx extension in client browser.

Hi everybody

I don't want to show up the *.aspx page extension. suppose the page link looks like this "http://www.xyz.com/products.aspx" means then, it should be display "http://www.xyz.com/products/" only.

and i want all other pages should be changed same as above

i want to be this done using Microsoft URL Rewrite module 2.0

Thanks in advance
Avatar of contactrobol
contactrobol

http://www.helicontech.com/
this is wht u need to use

URL Rewrite.
try this...
In global asax ..

Hope it helps...


If u want ur page as this, 
www.mysebsite.com/urlfriendly 
 
In ur Global asax page....
protected void Application_BeginRequest(object sender, EventArgs e)
    {
       string url_friendly = Request.Url.Query.ToString();
        if (url_friendly.EndsWith("urlfriendly")) // You can set condition here as per ur needs
          {                               
//U can use this loop , for storing session variables and can use further in redirected page..
HttpContext.Current.RewritePath("/foldername/default.aspx"); //this redirects to the page u want with the friendly url .Here virtual path is important....
          }
    }

Open in new window

Here are some links for URL Rewrite:

http://msdn.microsoft.com/en-us/library/ms972974.aspx
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/

You might also want to consider developing using MVC. In MVC, you'll have url's like "http://www.xyz.com/products/" directly.

Arun
Hi
u need somthing called URL Routing and not URL ReWriting
url rewriting is to change the url how it looks and make it more friendly

for you u need url routing
plz see this

http://msdn.microsoft.com/en-us/library/cc668201.aspx
You could write pages without aspx extension, but you must configure IIS to redirect all request to aspnet_isapi.dl.
Not sure if you have to add correct handler in web.config.
You could write pages without aspx extension, but you must configure IIS to redirect all request to aspnet_isapi.dl.
Not sure if you have to add correct handler in web.config
Avatar of K_CH_Krishna

ASKER

I am looking solution using the URL Rewrite Module 2.0 , IIS 7.0 and asp.net 4.0

regards

Krishna
ASKER CERTIFIED SOLUTION
Avatar of Kamal Khaleefa
Kamal Khaleefa
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is not exact answer. But given alternate way