472,811 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

HttpContext.RewritePath

I'd really appreciate it if someone would give me a"plain English"
explanation of HttpContext.RewritePath(). I read the MSDN documentation, but
still don't understand it.

According to MSDN:
.... assigns an internal rewrite path. RewritePath allows for the URL that is
requested to differ from the internal path to the resource.

What does this mean? When would it be useful to have the paths differ ?

Thanks.
Nov 18 '05 #1
5 2653
It is especially useful with HTTPHandlers.
You could have fancy user-specific URLs such as this:
http://www.mysite.com/GuadalaHarry

But this would really be redirected internally (using RewritePath) to a more
normal path such as:
http://www.mysite.com/userpage.aspx?user=GuadalaHarry

The user would get to use the nice URL and wouldn't ever have to know that
you've really structured pages on your server differently than it appears.
This also gives you the freedom to change your file/folder structure on your
server in the future without changing the URLs that your users are already
familiar with.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Guadala Harry" <gh****@aol.com> wrote in message
news:uv**************@TK2MSFTNGP10.phx.gbl...
I'd really appreciate it if someone would give me a"plain English"
explanation of HttpContext.RewritePath(). I read the MSDN documentation, but still don't understand it.

According to MSDN:
... assigns an internal rewrite path. RewritePath allows for the URL that is requested to differ from the internal path to the resource.

What does this mean? When would it be useful to have the paths differ ?

Thanks.

Nov 18 '05 #2
Thanks for the quick response! Exactly what I was looking for.
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
It is especially useful with HTTPHandlers.
You could have fancy user-specific URLs such as this:
http://www.mysite.com/GuadalaHarry

But this would really be redirected internally (using RewritePath) to a more normal path such as:
http://www.mysite.com/userpage.aspx?user=GuadalaHarry

The user would get to use the nice URL and wouldn't ever have to know that
you've really structured pages on your server differently than it appears.
This also gives you the freedom to change your file/folder structure on your server in the future without changing the URLs that your users are already
familiar with.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Guadala Harry" <gh****@aol.com> wrote in message
news:uv**************@TK2MSFTNGP10.phx.gbl...
I'd really appreciate it if someone would give me a"plain English"
explanation of HttpContext.RewritePath(). I read the MSDN documentation, but
still don't understand it.

According to MSDN:
... assigns an internal rewrite path. RewritePath allows for the URL

that is
requested to differ from the internal path to the resource.

What does this mean? When would it be useful to have the paths differ ?

Thanks.


Nov 18 '05 #3
This seems to be what I'm looking for too but I'm not sure where to use this

Where would you put a code that rewrites the path? In begin_request? Obviously the path has to be rewritten before the actual loading of a page begins, right

I would really appreciate a few lines of code just for example and where to put them for this to work

how to for example do what you wrote, when request URL is http://www.mysite.com/GuadalaHarry to have the application load http://www.mysite.com/userpage.aspx?user=GuadalaHarry instead

and is there any way for userpage.aspx to get the original request URL

----- Steve C. Orr [MVP, MCSD] wrote: ----

It is especially useful with HTTPHandlers
You could have fancy user-specific URLs such as this
http://www.mysite.com/GuadalaHarr

But this would really be redirected internally (using RewritePath) to a mor
normal path such as
http://www.mysite.com/userpage.aspx?user=GuadalaHarr

The user would get to use the nice URL and wouldn't ever have to know tha
you've really structured pages on your server differently than it appears
This also gives you the freedom to change your file/folder structure on you
server in the future without changing the URLs that your users are alread
familiar with

--
I hope this helps
Steve C. Orr, MCSD, MV
http://Steve.Orr.ne

"Guadala Harry" <gh****@aol.com> wrote in messag
news:uv**************@TK2MSFTNGP10.phx.gbl..
I'd really appreciate it if someone would give me a"plain English
explanation of HttpContext.RewritePath(). I read the MSDN documentation bu still don't understand it
According to MSDN ... assigns an internal rewrite path. RewritePath allows for the URL tha

i requested to differ from the internal path to the resource
What does this mean? When would it be useful to have the paths differ
Thanks

Nov 18 '05 #4
I saw an example of its use in a Page_Load event procedure (in a code-behind
module).

You can see it for yourself in the Community Starter Kit at
http://www.asp.net/Default.aspx?tabindex=9&tabid=47

HTH
"Adrijan Josic" <an*******@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
This seems to be what I'm looking for too but I'm not sure where to use this.
Where would you put a code that rewrites the path? In begin_request? Obviously the path has to be rewritten before the actual loading of a page
begins, right?
I would really appreciate a few lines of code just for example and where to put them for this to work.
how to for example do what you wrote, when request URL is http://www.mysite.com/GuadalaHarry to have the application load
http://www.mysite.com/userpage.aspx?user=GuadalaHarry instead?
and is there any way for userpage.aspx to get the original request URL?

----- Steve C. Orr [MVP, MCSD] wrote: -----

It is especially useful with HTTPHandlers.
You could have fancy user-specific URLs such as this:
http://www.mysite.com/GuadalaHarry

But this would really be redirected internally (using RewritePath) to a more normal path such as:
http://www.mysite.com/userpage.aspx?user=GuadalaHarry

The user would get to use the nice URL and wouldn't ever have to know that you've really structured pages on your server differently than it appears. This also gives you the freedom to change your file/folder structure on your server in the future without changing the URLs that your users are already familiar with.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Guadala Harry" <gh****@aol.com> wrote in message
news:uv**************@TK2MSFTNGP10.phx.gbl...
> I'd really appreciate it if someone would give me a"plain English"
> explanation of HttpContext.RewritePath(). I read the MSDN
documentation, but
> still don't understand it.
>> According to MSDN: > ... assigns an internal rewrite path. RewritePath allows for the

URL that is
> requested to differ from the internal path to the resource.
>> What does this mean? When would it be useful to have the paths differ ? >> Thanks.
>>

Nov 18 '05 #5
Correction to my last post:
The example I saw was in the Page_Init event handler (not Page_Load).

"Guadala Harry" <gh****@aol.com> wrote in message
news:ur****************@TK2MSFTNGP11.phx.gbl...
I saw an example of its use in a Page_Load event procedure (in a code-behind module).

You can see it for yourself in the Community Starter Kit at
http://www.asp.net/Default.aspx?tabindex=9&tabid=47

HTH
"Adrijan Josic" <an*******@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
This seems to be what I'm looking for too but I'm not sure where to use this.

Where would you put a code that rewrites the path? In begin_request?

Obviously the path has to be rewritten before the actual loading of a page
begins, right?

I would really appreciate a few lines of code just for example and where

to put them for this to work.

how to for example do what you wrote, when request URL is

http://www.mysite.com/GuadalaHarry to have the application load
http://www.mysite.com/userpage.aspx?user=GuadalaHarry instead?

and is there any way for userpage.aspx to get the original request URL?

----- Steve C. Orr [MVP, MCSD] wrote: -----

It is especially useful with HTTPHandlers.
You could have fancy user-specific URLs such as this:
http://www.mysite.com/GuadalaHarry

But this would really be redirected internally (using RewritePath) to a more
normal path such as:
http://www.mysite.com/userpage.aspx?user=GuadalaHarry

The user would get to use the nice URL and wouldn't ever have to
know that
you've really structured pages on your server differently than it appears.
This also gives you the freedom to change your file/folder

structure on your
server in the future without changing the URLs that your users are

already
familiar with.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Guadala Harry" <gh****@aol.com> wrote in message
news:uv**************@TK2MSFTNGP10.phx.gbl...
> I'd really appreciate it if someone would give me a"plain English" > explanation of HttpContext.RewritePath(). I read the MSDN

documentation,
but
> still don't understand it.
>> According to MSDN:
> ... assigns an internal rewrite path. RewritePath allows for the

URL that
is
> requested to differ from the internal path to the resource.
>> What does this mean? When would it be useful to have the paths

differ ? >> Thanks.
>>


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Aurel | last post by:
Hello, why HttpContext.RewritePath("path") doesn't work in IHttpmodule.AcquireRequestState ?!? Thanks Aurel
8
by: Jiho Han | last post by:
Can someone explain in layman's term, what HttpContext.RewritePath does? SDK doc explanation is kind of scant. Does it only affect the request processing for the duration of the processing(meaning...
1
by: marcmiles | last post by:
It looks like postbacks cause a problem with HttpContext.RewritePath. I've read about the two solutions below, but the first one seems extensive, and the scond one seems too easy. I sent an email...
15
by: James Higgs | last post by:
For a long time, our product has had a "vanity URLs" feature where nice URLs are mapped to ASPX files in an IHttpModule implementation, using HttpContext.RewritePath(). This has worked beautifully...
3
by: asanford | last post by:
I want to create an ASP.NET web application that receives a form POST message, inspects the data, and reroutes the request to one of many different servers. I wrote an IHttpModule which...
0
by: cpnet | last post by:
I was playing around with Beta 2 of VS2005, .NET 2.0, and built an IHttpModule do allow me to have nice URL's in my web app. It was working great. I had a URL like: ...
0
by: Martin | last post by:
asp.net 2.0 I have implemented the url rewriting using httpcontext.rewrite path( newpath, setbase) which all works fine in IE, but testing with fiddler ( www.fiddlertool.com) when you test...
2
by: Steven Nagy | last post by:
Hi all, I have the following file: ~/cms/page.aspx Normally, if you hit a url like http://localhost/MyApp/cms/page.aspx?PageID=32 ... this would load content dynamically. No big deal, this is...
1
by: jbitz | last post by:
Hi, This has got me really baffled. This has got me really baffled. When I run Dim url As String = HttpContext.Current.Request.Url.AbsolutePath.ToLower from Application_beginRequest in...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.