473,382 Members | 1,225 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,382 software developers and data experts.

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 5141
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

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

Similar topics

0
by: adlaird | last post by:
Hi, I created a simple webform, put a test button on it and implemented a click handler that looks like so: private void btnTest_Click(object sender, System.EventArgs e) {...
0
by: John | last post by:
I'm trying to create a context object similar to the HttpContext that could be used by business objects independent of the origin or the call (ASP.NET or standalone). So I started out by...
0
by: theintrepidfox | last post by:
Dear Group I came accross a very annoying behaviour of Visual Studio, giving me six hours of headache till I found the solution. This post is mainly for fellow developers for reference as it...
5
by: Archer | last post by:
I was making a role-based authentication but it does't login with correct password. the HttpContext.Current.User recieved in Global.asax is always null. Request.IsAuthenticated is always false....
0
by: jensen bredal | last post by:
the code below works as expected when i'm doing localhost developpement on my win xp pro but when moved onto production server( windows 2003 server) and viewing from my win xp pc, then UserIndexA...
16
by: Victor | last post by:
I have a strange problem in my website. I configured my website to run under 2 worker processes. (web garden enabled). and I stored my user information in the current httpcontext(like...
2
by: f0zzyNUE | last post by:
hi everyone, currently we are testing the performance our application (asp.net based CMS) ... for that reason we wrote a "spider" that starts webrequests for all relevant pages which results in...
8
by: eric | last post by:
I have a 2.0 asp.net project. In a class contained within a seperate project, I am trying to reference HttpContext.Current.Session but Session is always null. I've tried implementing...
3
by: Brett R. Wesoloski | last post by:
I am having problems using HttpContext.Current.Request.Url.Host. I have some code that does this... if (HttpContext.Current != null) { subdomain = HttpContext.Current.Request.Url.Host; }
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.