Pre-Interpreting a Request

G

Guest

Hi. I have an ASP.NET (in C#) application. Most of the application works the
way they usually do: an .aspx is requested and the code for that .aspx
processes the request, etc.

But undere one (and ONLY one) of my directories inside the application
(site), I need to parse the requesting Url BEFORE IIS (or is it ASP.NET)
attempts to open the requested resource. This is because the request resource
will actually NOT EXIST. Instead, a redirect will be performed OR the
response will just dynamically be generated.

EXAMPLE:

URL 1: http://site.com/NormalStuff/Default.aspx: This will be handled
completely normally and "Default.aspx must exist, etc.

URL 2: http://site.com/ParseIt/XYZ-PDQ.LMNOP: In this case, anything under
the "ParseIt" directory will be "intercepted" and the URL will be parsed by
my code to figure out what to do.

HOW DO I DO THIS IN ASP.NET? Is it something I have to insert in Global.asax?

Help?

Thanks.

Alex Maghen
 
J

John Saunders

Alex Maghen said:
Hi. I have an ASP.NET (in C#) application. Most of the application works
the
way they usually do: an .aspx is requested and the code for that .aspx
processes the request, etc.

But undere one (and ONLY one) of my directories inside the application
(site), I need to parse the requesting Url BEFORE IIS (or is it ASP.NET)
attempts to open the requested resource. This is because the request
resource
will actually NOT EXIST. Instead, a redirect will be performed OR the
response will just dynamically be generated.

EXAMPLE:

URL 1: http://site.com/NormalStuff/Default.aspx: This will be handled
completely normally and "Default.aspx must exist, etc.

URL 2: http://site.com/ParseIt/XYZ-PDQ.LMNOP: In this case, anything under
the "ParseIt" directory will be "intercepted" and the URL will be parsed
by
my code to figure out what to do.

HOW DO I DO THIS IN ASP.NET? Is it something I have to insert in
Global.asax?

Alex, the big question is: why would IIS ever call ASP.NET for a URL like
http://site.com/ParseIt/XYZ-PDQ.LMNOP?

IIS maps requests to ISAPI DLLs (including the aspnet_isapi dll) based on
the file extension. In the above URL, you have no file extension and XYZ...
isn't even a real directory. If it were a real (or virtual) directory, you
could set up a default document of something.aspx and that would cause
ASP.NET to be called.

What's wrong with something like http://site.com/ParseIt.aspx?XYZ... ?


John Saunders
 
G

Guest

John -

Thanks for getting back to me SO fast. I understand what you're saying and
you're right. So let me be more specific: What I really meant to say is that
I want to have requests made to a URL like these:

http://site.com/ParseIt/Data01.xml
http://site.com/ParseIt/Data02.xml

actually result in a call to a something like this:

http://site.com/Data/Data.aspx?ID=1
http://site.com/Data/Data.aspx?ID=2

This is because I have no control over the client (which is constructed to
request FILES and not URLs with QueryString parameters.

So what do you think? Thanks again.

Alex
 
J

John Saunders

Alex Maghen said:
John -

Thanks for getting back to me SO fast. I understand what you're saying and
you're right. So let me be more specific: What I really meant to say is
that
I want to have requests made to a URL like these:

http://site.com/ParseIt/Data01.xml
http://site.com/ParseIt/Data02.xml

actually result in a call to a something like this:

http://site.com/Data/Data.aspx?ID=1
http://site.com/Data/Data.aspx?ID=2

This is because I have no control over the client (which is constructed to
request FILES and not URLs with QueryString parameters.

So what do you think? Thanks again.

Ok, that's easier. :)

Configure the IIS virtual directory ParseIt to pass .xml files to
aspnet_isapi.dll. Configure .xml the same way that .aspx is configured.

Then, create an HttpModule, say, ParseItModule, and configure it in the
web.config for the ParseIt directory. It will perform "URL Rewriting" (see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp
for details).


John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top