473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 2717
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.