Last post Dec 15, 2008 07:33 PM by gdoten
Dec 11, 2008 04:32 PM|gdoten|LINK
Is the URL, as entered in a browser, available in the Request object or any other object? The problem is that if I enter a URL like this in a browser:
and look at the Request.Url property or Request.Params["URL"] from the Application_BeginRequest event it looks like this:
See how the filename part (default.aspx) is there. It appears that ASPX always puts the filename in this property, as if it always builds up this property from the full name of the executing page.
What I would like to do is if the specified URL has a default page filename (default.aspx, index.html, or whatever is defined for the site) then redirect to the same URL without the explicit filename. I've written code that checks for this and does the redirect,
but it goes into an endless loop because even though no filename is in the URL for the requested page, ASPX seems to be adding it in the property's value, so the code thinks it needs to redirect again. The browser shows the URL without the filename but there
it is in the property.
(This forum seemed to be the place to post this question since I'd like to move this code into an HTTP Module but right now it's in the global.asax file.)
Dec 11, 2008 08:59 PM|jgangwisch|LINK
if you had the url:
then you would access these variables through
request.querystring("a") 'which will return "1"
request.querystring("b") 'which will return "2"
request.querystring("flag_c") 'which will return ""
Dec 11, 2008 09:11 PM|dahla|LINK
In your IIS configuration there is a set of default pages which the IIS will redirect to if a folder is requested.
That is why you are experiencing an endless loop where IIS redirects to default.aspx, you redirect to / and IIS redirects to default.aspx and so forth.
A long story short, you are not able to do what you want to do. It is not possible to execute a folder but only a specific page and therefore you cannot get rid of the actual filename
Dec 15, 2008 03:04 PM|gdoten|LINK
I'm surprised there's no way to find out what the exact string in the user's browser's address field is (i.e., the actual string used to request the page with).
Dec 15, 2008 06:33 PM|dahla|LINK
Okay, if that is what you are looking for you should try looking at
(or Request.RawUrl for short if in a page)
I thought your problem was related to the redirection.
Dec 15, 2008 07:33 PM|gdoten|LINK
RawUrl is the problem; unfortunately, it doesn't actually give the "raw" URL as sent to the Web server. Even though the browser's address field is showing this (and the IIS log files confirm this to be the requested URL):
RawUrl returns this value:
All of the Request properties appear to tack the page's filename onto the URL, whether one was explicitly specified or not. Even the ALL_RAW server variable has this problem.
Thanks for the idea though.