473,545 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: HttpContext.Rew ritePath

Can someone explain in layman's term, what HttpContext.Rew ritePath does?
SDK doc explanation is kind of scant.
Does it only affect the request processing for the duration of the
processing(mean ing server side), or is the client in anyway affected?

Thanks
Nov 18 '05 #1
8 1838
From what I understand is it rewrite the URL appear on your browser.

"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:Od******** *****@TK2MSFTNG P10.phx.gbl...
Can someone explain in layman's term, what HttpContext.Rew ritePath does?
SDK doc explanation is kind of scant.
Does it only affect the request processing for the duration of the
processing(mean ing server side), or is the client in anyway affected?

Thanks

Nov 18 '05 #2
RewritePath is used when you are using some url munging scheme.

say you want your urls to look like

http://mysite.com/myapp/tv/listproducts.aspx
http://mysite.com/myapp/10001/listproducts.aspx

instead of

http://mysite.com/myapp/listproducts.aspx?type=tv
http://mysite.com/myapp/listproducts...stomerid=10001

you could write a httpmodule using RewritePath translate the incoming url,
to valid path to the apsx page.

-- bruce (sqlwork.com)
"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:Od******** *****@TK2MSFTNG P10.phx.gbl...
Can someone explain in layman's term, what HttpContext.Rew ritePath does?
SDK doc explanation is kind of scant.
Does it only affect the request processing for the duration of the
processing(mean ing server side), or is the client in anyway affected?

Thanks

Nov 18 '05 #3
Let say browser sent a request for /mysite/my.aspx
HttpContext.Rew rite kicks in before that aspx processed and rewrites it to
/mysite/template1/notmy.aspx.

From now on the ASP.NET engine will see that request as if came to
/mysite/template1/notmy.aspx pretty much ignoring the original request for
/mysite/my.aspx

You see??? You just rewrote the URL.

The client is unaffected in anyway (ALMOST). Since it thinks that it still
gets the HTML from /mysite/my.aspx
Guess why i have that almost there? I was amazed that practically any
article or sample of using that HttpContext.Rew rite does not mention one
small but important problem

The <form> action will be /mysite/template1/notmy.aspx
So the next time you click submit button you will clearly see in the browser
full url.
Of course there is an easy workaround "In a page_load event rewrite url back
to the original"

Another thing is you must be careful with path you specify to images or js
files.
If you use relative path browser will convert it to full path and send
request to the server. And since browser has no idea that URL was rewritten
it will ask for
/mysite/my.gif not /mysite/template1/my.gif. Which might be not what you
expected.
So it's probably better to specify the full path for images and ohter
related to the page files.
George.
"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:Od******** *****@TK2MSFTNG P10.phx.gbl...
Can someone explain in layman's term, what HttpContext.Rew ritePath does?
SDK doc explanation is kind of scant.
Does it only affect the request processing for the duration of the
processing(mean ing server side), or is the client in anyway affected?

Thanks

Nov 18 '05 #4
I see. I am most interested to find out what the behavior is on the client
side.
I think now I understand why when I used HttpContext.Rew ritePath on my
initial post(!IsPostBac k), the postback url was changed to the rewritten
path via form action attribute.
And as for non-aspx page resources, it's because those are handled by IIS
not ASP.NET, isn't it?

Bear with me one more time.
The sdk doc states: "RewritePat h is used in cookieless session state." How
might RewritePath be used in a cookieless session state?

Thank you.
Jiho

"George Ter-Saakov" <no****@hotmail .com> wrote in message
news:us******** ******@TK2MSFTN GP11.phx.gbl...
Let say browser sent a request for /mysite/my.aspx
HttpContext.Rew rite kicks in before that aspx processed and rewrites it to
/mysite/template1/notmy.aspx.

From now on the ASP.NET engine will see that request as if came to
/mysite/template1/notmy.aspx pretty much ignoring the original request for
/mysite/my.aspx

You see??? You just rewrote the URL.

The client is unaffected in anyway (ALMOST). Since it thinks that it still
gets the HTML from /mysite/my.aspx
Guess why i have that almost there? I was amazed that practically any
article or sample of using that HttpContext.Rew rite does not mention one
small but important problem

The <form> action will be /mysite/template1/notmy.aspx
So the next time you click submit button you will clearly see in the browser full url.
Of course there is an easy workaround "In a page_load event rewrite url back to the original"

Another thing is you must be careful with path you specify to images or js
files.
If you use relative path browser will convert it to full path and send
request to the server. And since browser has no idea that URL was rewritten it will ask for
/mysite/my.gif not /mysite/template1/my.gif. Which might be not what you
expected.
So it's probably better to specify the full path for images and ohter
related to the page files.
George.
"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:Od******** *****@TK2MSFTNG P10.phx.gbl...
Can someone explain in layman's term, what HttpContext.Rew ritePath does?
SDK doc explanation is kind of scant.
Does it only affect the request processing for the duration of the
processing(mean ing server side), or is the client in anyway affected?

Thanks


Nov 18 '05 #5
Have you ever saw the burl of the cookieless browser?
Here is an example if you did not (Go to http://mappoint.msn.com)

It will redirect you automatically to something like
http://mappoint.msn.com/(mmagffm234v...v55)/Home.aspx

This (mmagffm234v5vp mbik0oev55) is your session identifier.

I hope you do not believe that this folder (mmagffm234v5vp mbik0oev55)
actually exist on the server.

When you hit that URL asp engine rewrites url to
http://mappoint.msn.com/Home.aspx and setting correctly session object to
the one identified by (mmagffm234v5vp mbik0oev55)

You still have to watch out how do you reference images.
Since browser is not aware of those rewrites and will try to retrieve an
image from
http://mappoint.msn.com/(mmagffm234v...0oev55)/my.gif if you used
relative path to it.
George.

"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I see. I am most interested to find out what the behavior is on the client side.
I think now I understand why when I used HttpContext.Rew ritePath on my
initial post(!IsPostBac k), the postback url was changed to the rewritten
path via form action attribute.
And as for non-aspx page resources, it's because those are handled by IIS
not ASP.NET, isn't it?

Bear with me one more time.
The sdk doc states: "RewritePat h is used in cookieless session state." How might RewritePath be used in a cookieless session state?

Thank you.
Jiho

Nov 18 '05 #6
Thanks George, for that example.

I've actually seen them before and I've also seen this variation:

http://mappoint.msn.com/Home.aspx/mm...v5vpmbik0oev55 (Not at mappoint,
this probably won't work here)

So what is the difference between doing it this way instead of using the
querystring like this? To be precise, what benefits do you gain?

http://mappoint.msn.com/Home.aspx?si...v5vpmbik0oev55

You've been most helpful.
Jiho

"George Ter-Saakov" <no****@hotmail .com> wrote in message
news:u4******** ******@TK2MSFTN GP12.phx.gbl...
Have you ever saw the burl of the cookieless browser?
Here is an example if you did not (Go to http://mappoint.msn.com)

It will redirect you automatically to something like
http://mappoint.msn.com/(mmagffm234v...v55)/Home.aspx

This (mmagffm234v5vp mbik0oev55) is your session identifier.

I hope you do not believe that this folder (mmagffm234v5vp mbik0oev55)
actually exist on the server.

When you hit that URL asp engine rewrites url to
http://mappoint.msn.com/Home.aspx and setting correctly session object to
the one identified by (mmagffm234v5vp mbik0oev55)

You still have to watch out how do you reference images.
Since browser is not aware of those rewrites and will try to retrieve an
image from
http://mappoint.msn.com/(mmagffm234v...0oev55)/my.gif if you used
relative path to it.
George.

"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I see. I am most interested to find out what the behavior is on the

client
side.
I think now I understand why when I used HttpContext.Rew ritePath on my
initial post(!IsPostBac k), the postback url was changed to the rewritten
path via form action attribute.
And as for non-aspx page resources, it's because those are handled by IIS not ASP.NET, isn't it?

Bear with me one more time.
The sdk doc states: "RewritePat h is used in cookieless session state."

How
might RewritePath be used in a cookieless session state?

Thank you.
Jiho


Nov 18 '05 #7
As for embed session into the url. you will get the benefit that all relative links to other pages will automatically carryover session id.

Let say you have a page http://mappoint.msn.co m/{seesionid}/mypage.aspx
and you have a link <a href="mypage2.a spx">

The sessionid will be automaticly transfered to mypage2.aspx

The overal benefit of URL rewriting is to create human readable urls.

George
My Site - Body Jewelry
"Jiho Han" <ji******@infin ityinfo.com> wrote in message news:e$******** ******@TK2MSFTN GP10.phx.gbl...
Thanks George, for that example.

I've actually seen them before and I've also seen this variation:

http://mappoint.msn.com/Home.aspx/mm...v5vpmbik0oev55 (Not at mappoint,
this probably won't work here)

So what is the difference between doing it this way instead of using the
querystring like this? To be precise, what benefits do you gain?

http://mappoint.msn.com/Home.aspx?si...v5vpmbik0oev55

You've been most helpful.
Jiho

"George Ter-Saakov" <no****@hotmail .com> wrote in message
news:u4******** ******@TK2MSFTN GP12.phx.gbl...
Have you ever saw the burl of the cookieless browser?
Here is an example if you did not (Go to http://mappoint.msn.com)

It will redirect you automatically to something like
http://mappoint.msn.com/(mmagffm234v...v55)/Home.aspx

This (mmagffm234v5vp mbik0oev55) is your session identifier.

I hope you do not believe that this folder (mmagffm234v5vp mbik0oev55)
actually exist on the server.

When you hit that URL asp engine rewrites url to
http://mappoint.msn.com/Home.aspx and setting correctly session object to
the one identified by (mmagffm234v5vp mbik0oev55)

You still have to watch out how do you reference images.
Since browser is not aware of those rewrites and will try to retrieve an
image from
http://mappoint.msn.com/(mmagffm234v...0oev55)/my.gif if you used
relative path to it.
George.

"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I see. I am most interested to find out what the behavior is on the

client
side.
I think now I understand why when I used HttpContext.Rew ritePath on my
initial post(!IsPostBac k), the postback url was changed to the rewritten
path via form action attribute.
And as for non-aspx page resources, it's because those are handled by IIS not ASP.NET, isn't it?

Bear with me one more time.
The sdk doc states: "RewritePat h is used in cookieless session state."

How
might RewritePath be used in a cookieless session state?

Thank you.
Jiho


Nov 18 '05 #8
Oh I see what you mean by the session info being carried over to other pages without attaching querystring to every page.

Thanks.
"George" <no****@hotmail .com> wrote in message news:ev******** ********@TK2MSF TNGP11.phx.gbl. ..
As for embed session into the url. you will get the benefit that all relative links to other pages will automatically carryover session id.

Let say you have a page http://mappoint.msn.co m/{seesionid}/mypage.aspx
and you have a link <a href="mypage2.a spx">

The sessionid will be automaticly transfered to mypage2.aspx

The overal benefit of URL rewriting is to create human readable urls.

George
My Site - Body Jewelry
"Jiho Han" <ji******@infin ityinfo.com> wrote in message news:e$******** ******@TK2MSFTN GP10.phx.gbl...
Thanks George, for that example.

I've actually seen them before and I've also seen this variation:

http://mappoint.msn.com/Home.aspx/mm...v5vpmbik0oev55 (Not at mappoint,
this probably won't work here)

So what is the difference between doing it this way instead of using the
querystring like this? To be precise, what benefits do you gain?

http://mappoint.msn.com/Home.aspx?si...v5vpmbik0oev55

You've been most helpful.
Jiho

"George Ter-Saakov" <no****@hotmail .com> wrote in message
news:u4******** ******@TK2MSFTN GP12.phx.gbl...
Have you ever saw the burl of the cookieless browser?
Here is an example if you did not (Go to http://mappoint.msn.com)

It will redirect you automatically to something like
http://mappoint.msn.com/(mmagffm234v...v55)/Home.aspx

This (mmagffm234v5vp mbik0oev55) is your session identifier.

I hope you do not believe that this folder (mmagffm234v5vp mbik0oev55)
actually exist on the server.

When you hit that URL asp engine rewrites url to
http://mappoint.msn.com/Home.aspx and setting correctly session object to
the one identified by (mmagffm234v5vp mbik0oev55)

You still have to watch out how do you reference images.
Since browser is not aware of those rewrites and will try to retrieve an
image from
http://mappoint.msn.com/(mmagffm234v...0oev55)/my.gif if you used
relative path to it.
George.

"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I see. I am most interested to find out what the behavior is on the

client
side.
I think now I understand why when I used HttpContext.Rew ritePath on my
initial post(!IsPostBac k), the postback url was changed to the rewritten
path via form action attribute.
And as for non-aspx page resources, it's because those are handled by IIS not ASP.NET, isn't it?

Bear with me one more time.
The sdk doc states: "RewritePat h is used in cookieless session state."

How
might RewritePath be used in a cookieless session state?

Thank you.
Jiho


Nov 18 '05 #9

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

Similar topics

5
2734
by: Guadala Harry | last post by:
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...
1
1637
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 to the author of the second one for more info.......but no reply. http://weblogs.asp.net/jezell/archive/2004/03/15/90045.aspx...
15
6692
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 for the past couple of years under .NET 1.1, but when it runs under ASP.NET 2.0 it has problems. Note that this is the case regardless of whether...
3
2915
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 successfully used HttpContext.RewritePath() to send a request to different pages in one web application, but it gives me an error when I try to rewrite a path...
0
1427
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: http://mydomain.com/Users/BobSmith/ or http://mydomain.com/Users/BobSmith The "BobSmith" didn't actually exist. My HttpModule would use RewritePath method to return a...
0
1370
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 Mozilla 5.0 UserAgent - it generates a http 500 error. This is bad because none of those pages will get indexed by google or Yahoo etc and any other...
2
2985
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 common right? So now I want to do some URL rewritting. I want to map:
1
5155
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 Global.asax with server that ships with Visual Web Developer everything works as expected. However, today when I tried to move all code onto IIS server this...
1
1803
by: mmorrison93 | last post by:
Thanks in advance for any help on this problem, but i have an HttpHandler that looks at the requested url and and tranfers context to a particular file. The problem is the transfer will only work if the file is located in the root directory, if I try to transfer context to a file in a subdirectory the Server.Transfer method returns an error,...
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7446
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5349
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.