Pre-Interpreting a Request

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxleCBNYWdoZW4=?=, Nov 14, 2004.

  1. 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
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Nov 14, 2004
    #1
    1. Advertising

  2. "Alex Maghen" <> wrote in message
    news:D...
    > 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
    John Saunders, Nov 14, 2004
    #2
    1. Advertising

  3. 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


    "John Saunders" wrote:

    > "Alex Maghen" <> wrote in message
    > news:D...
    > > 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
    >
    >
    >
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Nov 14, 2004
    #3
  4. "Alex Maghen" <> wrote in message
    news:...
    > 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
    John Saunders, Nov 14, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rocky Moore
    Replies:
    7
    Views:
    1,702
    mikeb
    Jan 14, 2004
  2. =?Utf-8?B?S2V2aW4gQnVydG9u?=

    Pre-Send Request Headers, Pre-Send Request Content

    =?Utf-8?B?S2V2aW4gQnVydG9u?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,019
    =?Utf-8?B?S2V2aW4gQnVydG9u?=
    Dec 31, 2004
  3. Wladimir Borsov
    Replies:
    7
    Views:
    457
    Raymond Loman
    May 5, 2004
  4. Juha Nieminen
    Replies:
    3
    Views:
    1,118
    Juha Nieminen
    Feb 22, 2008
  5. Chris M. Thomasson
    Replies:
    10
    Views:
    633
    Nobody
    Aug 29, 2009
Loading...

Share This Page