473,405 Members | 2,444 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,405 software developers and data experts.

Q: HttpContext.RewritePath

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 server side), or is the client in anyway affected?

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

"Jiho Han" <ji******@infinityinfo.com> wrote in message
news:Od*************@TK2MSFTNGP10.phx.gbl...
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 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******@infinityinfo.com> wrote in message
news:Od*************@TK2MSFTNGP10.phx.gbl...
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 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.Rewrite 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.Rewrite 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******@infinityinfo.com> wrote in message
news:Od*************@TK2MSFTNGP10.phx.gbl...
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 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.RewritePath on my
initial post(!IsPostBack), 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: "RewritePath 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**************@TK2MSFTNGP11.phx.gbl...
Let say browser sent a request for /mysite/my.aspx
HttpContext.Rewrite 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.Rewrite 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******@infinityinfo.com> wrote in message
news:Od*************@TK2MSFTNGP10.phx.gbl...
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 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 (mmagffm234v5vpmbik0oev55) is your session identifier.

I hope you do not believe that this folder (mmagffm234v5vpmbik0oev55)
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 (mmagffm234v5vpmbik0oev55)

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******@infinityinfo.com> wrote in message
news:%2****************@TK2MSFTNGP10.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.RewritePath on my
initial post(!IsPostBack), 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: "RewritePath 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**************@TK2MSFTNGP12.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 (mmagffm234v5vpmbik0oev55) is your session identifier.

I hope you do not believe that this folder (mmagffm234v5vpmbik0oev55)
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 (mmagffm234v5vpmbik0oev55)

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******@infinityinfo.com> wrote in message
news:%2****************@TK2MSFTNGP10.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.RewritePath on my
initial post(!IsPostBack), 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: "RewritePath 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.com/{seesionid}/mypage.aspx
and you have a link <a href="mypage2.aspx">

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******@infinityinfo.com> wrote in message news:e$**************@TK2MSFTNGP10.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**************@TK2MSFTNGP12.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 (mmagffm234v5vpmbik0oev55) is your session identifier.

I hope you do not believe that this folder (mmagffm234v5vpmbik0oev55)
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 (mmagffm234v5vpmbik0oev55)

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******@infinityinfo.com> wrote in message
news:%2****************@TK2MSFTNGP10.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.RewritePath on my
initial post(!IsPostBack), 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: "RewritePath 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****************@TK2MSFTNGP11.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.com/{seesionid}/mypage.aspx
and you have a link <a href="mypage2.aspx">

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******@infinityinfo.com> wrote in message news:e$**************@TK2MSFTNGP10.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**************@TK2MSFTNGP12.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 (mmagffm234v5vpmbik0oev55) is your session identifier.

I hope you do not believe that this folder (mmagffm234v5vpmbik0oev55)
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 (mmagffm234v5vpmbik0oev55)

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******@infinityinfo.com> wrote in message
news:%2****************@TK2MSFTNGP10.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.RewritePath on my
initial post(!IsPostBack), 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: "RewritePath 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
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:...
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.