Link to home
Start Free TrialLog in
Avatar of noel58
noel58

asked on

How do I convert a URL in ASP.Net

I'm trying to use Context.RewritePath in protected void Application_BeginRequest to rewrite a URL but without much luck.

I want to be able to take the URL

http://secure.myapp.com/customer/atlascs

and convert this using a rewrite to

http://secure.myapp.com/Login.aspx?customer=atlascs

I've tried to use the code supplied but with no luck as I simply get told that my page cannot be found.  Any suggestions are welcomed
string fullOrigionalpath = Request.Url.ToString();
 
            if (fullOrigionalpath.Contains("/customer/"))
            {
                string customer = fullOrigionalpath.Substring(fullOrigionalpath.LastIndexOf("/"));
                Context.RewritePath("/Login.aspx?customer=" + customer);
            }

Open in new window

Avatar of mohan_sekar
mohan_sekar
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of Saqib Khan
Saqib Khan
Flag of United States of America 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