Solved

How do I convert a URL in ASP.Net

Posted on 2009-07-13
2
192 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
ID: 24844591
0
 
LVL 23

Accepted Solution

by:
Saqib Khan earned 500 total points
ID: 24846530
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

813 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

14 Experts available now in Live!

Get 1:1 Help Now