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

Home Posts Topics Members FAQ

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

Strange HttpContext.Request.Url Problem

1
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.ToLow er 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 just doesn't return the same URL!

On localhost (Visual Web Developer), variable url is /sandbox/my/home/page, but on IIS it returns /sandbox/index.aspx.

Yes, this is another HttpContext.RewritePath application which is why I need to know what the user types as a URL event though a 404 error is expected.

Let's say my root directory has only the following files:

* index.aspx
* web.config
* global.asax

When the user visits, for example: http://www.mysite.com/tutorials/tute/1

The global.asax file should be able to grab this URL using HttpContext.Current.Request.Url.AbsolutePath.ToLow er method and I will use this string to formulate a RewritePath to index.aspx?a=tutorials&tute=1.

As you can see, the directories tutorials, tute and 01 don't exist, so there is no index.aspx file to refer to.

My problem is, IIS and HttpContext.AbsolutePath isn't giving me http://www.mysite.com/tutorials/tute/1 or any of the variables. But the strange thing is, this is all working on localhost.

So it makes me wonder if it's something to do with IIS, or if there is another way to get the typed URL.


Any help is greatly appreciated.

Thanks,

Jason.
Jun 15 '07 #1
1 4895
Spanco
13
Hi ....

Just try a tiddle sign(~) in place of server.mappath and see what happened and please get back to me we both will solved it,waiting for response

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.ToLow er 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 just doesn't return the same URL!

On localhost (Visual Web Developer), variable url is /sandbox/my/home/page, but on IIS it returns /sandbox/index.aspx.

Yes, this is another HttpContext.RewritePath application which is why I need to know what the user types as a URL event though a 404 error is expected.

Let's say my root directory has only the following files:

* index.aspx
* web.config
* global.asax

When the user visits, for example: http://www.mysite.com/tutorials/tute/1

The global.asax file should be able to grab this URL using HttpContext.Current.Request.Url.AbsolutePath.ToLow er method and I will use this string to formulate a RewritePath to index.aspx?a=tutorials&tute=1.

As you can see, the directories tutorials, tute and 01 don't exist, so there is no index.aspx file to refer to.

My problem is, IIS and HttpContext.AbsolutePath isn't giving me http://www.mysite.com/tutorials/tute/1 or any of the variables. But the strange thing is, this is all working on localhost.

So it makes me wonder if it's something to do with IIS, or if there is another way to get the typed URL.


Any help is greatly appreciated.

Thanks,

Jason.
Jul 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by adlaird | last post: by
reply views Thread by John | last post: by
reply views Thread by theintrepidfox | last post: by
5 posts views Thread by Archer | last post: by
reply views Thread by jensen bredal | last post: by
16 posts views Thread by Victor | last post: by
8 posts views Thread by eric | last post: by
3 posts views Thread by Brett R. Wesoloski | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.