468,554 Members | 1,418 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

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 2405
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Aurel | last post: by
8 posts views Thread by Jiho Han | last post: by
1 post views Thread by marcmiles | last post: by
15 posts views Thread by James Higgs | last post: by
3 posts views Thread by asanford | last post: by
2 posts views Thread by Steven Nagy | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.