Posted By: DuNuNuBatman | Oct 26th, 2005 @ 2:09 PM
page 1 of 1
Comments: 4 | Views: 5554
I am having the hardest time getting this to work. I have been playing around with the HttpContext.RewritePath Method because I am trying to take this:
http://mywebsite.com/Redir/Default.aspx?userID=jdale and make it so when the browser requests this http://mywebsite.com/Redir/jdale it will return the query string userID... or something similar, I just can't have query strings in the url, it has to look like a directory request.
Anyway, one of the problems I am having is the HttpContext.RewritePath Method is extremelly poorly documented. (like most other things in the msdn documentation, but that is another rant)...
Anyway, here is the code I have in the Global.asax file.

void Application_Start(Object sender, EventArgs e)
{
    HttpContext httpCont = HttpContext.Current;
    httpCont.RewritePath("~/Redir", "", "");
}

You may be wondering why there isn't anything in the other arguments... well that is because I don't know how to use them.

Anyway, when the ~/Redir/Default.aspx page is requested as such: http://mywebsie.com/Redir/jdale
it will get the query string userid=jdale
AdamKinney
AdamKinney
Agent of Change
If you don't need Postback functionality here's a quick fix for friendly urls.
Maurits
Maurits
AKA Matthew van Eerde
Make a custom 404 handler for the /Redir/ directory
Parse the username from the Request.RawUrl (see Adam's code)
Do a Response.Redirect to the page with the content

Not sure what you mean by "DNS Redirect" -- you mean, CNAME?
page 1 of 1
Comments: 4 | Views: 5554