Solved

How do I convert a URL in ASP.Net

Posted on 2009-07-13
2
185 Views
Last Modified: 2013-11-08
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

0
Comment
Question by:noel58
2 Comments
 
LVL 15

Expert Comment

by:mohan_sekar
Comment Utility
0
 
LVL 23

Accepted Solution

by:
adilkhan earned 500 total points
Comment Utility
I wrote a Tutorial for this.

http://www.knowlegezone.com/documents/89/Simple-AspNet-Url-Rewriting-Tutorial-Http-Modules/


However did you register your HTTP MODULE in web.config? if not then please Follow my above tutorial.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now