Introduce new filetype with httphandler

Discussion in 'ASP .Net' started by =?Utf-8?B?UGF1bA==?=, Jun 15, 2005.

  1. Hi!

    I want my web application to be able to handle files with the extension
    ..mspx (my own extension). The new extension should be handled exatly the way
    aspx files are handled, but with some additional code specific to the .mspx
    extension files.

    I thought this would be an easy task, but maby I've cornored myself into a
    wrong path. I've set the mapping correct in IIS, so that asp.net manages the
    new extension. I've also created a class that inherits from the IHttpHandler
    interface. This custom HttpHandler is also registered in web.config.

    So far so good, but I've not figured out how to implement the content of the
    custom HttpHandler, so that it first goes throuht my custom code, and then
    let the Page class handle the rest.

    Any ideas?

    Thanx!
    Paul
     
    =?Utf-8?B?UGF1bA==?=, Jun 15, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?UGF1bA==?=

    Brock Allen Guest

    You can try Server.Transfer to process the ASPX page. Depending upon what
    you need to do, you could instead implement IHttpHandlerFactory and do what
    you need to in GetHandler, then delegate to the built in PageHandlerFactory.
    Or from your HttpHandler simply call into PageHandlerFactory to get the ASPX
    handler then call its ProcessRequest directly.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi!
    >
    > I want my web application to be able to handle files with the
    > extension .mspx (my own extension). The new extension should be
    > handled exatly the way aspx files are handled, but with some
    > additional code specific to the .mspx extension files.
    >
    > I thought this would be an easy task, but maby I've cornored myself
    > into a wrong path. I've set the mapping correct in IIS, so that
    > asp.net manages the new extension. I've also created a class that
    > inherits from the IHttpHandler interface. This custom HttpHandler is
    > also registered in web.config.
    >
    > So far so good, but I've not figured out how to implement the content
    > of the custom HttpHandler, so that it first goes throuht my custom
    > code, and then let the Page class handle the rest.
    >
    > Any ideas?
    >
    > Thanx!
    > Paul
     
    Brock Allen, Jun 15, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?UGF1bA==?=

    Bruce Barker Guest

    if you your handler wants the normal process, it has to call it. there is
    only one handler per request. look at httpmodules, this may be what you want
    instead. if you want to call asp,net to process the message, you must create
    the asp.net page handelr yourslf, and call it. see
    PageParser.GetCompilerPageInstance(), which returns a handler you can call.

    -- bruce (sqlwork.com)





    "Paul" <> wrote in message
    news:...
    > Hi!
    >
    > I want my web application to be able to handle files with the extension
    > .mspx (my own extension). The new extension should be handled exatly the
    > way
    > aspx files are handled, but with some additional code specific to the
    > .mspx
    > extension files.
    >
    > I thought this would be an easy task, but maby I've cornored myself into a
    > wrong path. I've set the mapping correct in IIS, so that asp.net manages
    > the
    > new extension. I've also created a class that inherits from the
    > IHttpHandler
    > interface. This custom HttpHandler is also registered in web.config.
    >
    > So far so good, but I've not figured out how to implement the content of
    > the
    > custom HttpHandler, so that it first goes throuht my custom code, and then
    > let the Page class handle the rest.
    >
    > Any ideas?
    >
    > Thanx!
    > Paul
     
    Bruce Barker, Jun 15, 2005
    #3
  4. Thanx, I already solved the problem using
    PageParser.GetCompilerPageInstance() (as you also sugested).
    I hope there are no performence downsides or any other downsides for that
    matter using this method.


    "Bruce Barker" wrote:

    > if you your handler wants the normal process, it has to call it. there is
    > only one handler per request. look at httpmodules, this may be what you want
    > instead. if you want to call asp,net to process the message, you must create
    > the asp.net page handelr yourslf, and call it. see
    > PageParser.GetCompilerPageInstance(), which returns a handler you can call.
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    >
    >
    > "Paul" <> wrote in message
    > news:...
    > > Hi!
    > >
    > > I want my web application to be able to handle files with the extension
    > > .mspx (my own extension). The new extension should be handled exatly the
    > > way
    > > aspx files are handled, but with some additional code specific to the
    > > .mspx
    > > extension files.
    > >
    > > I thought this would be an easy task, but maby I've cornored myself into a
    > > wrong path. I've set the mapping correct in IIS, so that asp.net manages
    > > the
    > > new extension. I've also created a class that inherits from the
    > > IHttpHandler
    > > interface. This custom HttpHandler is also registered in web.config.
    > >
    > > So far so good, but I've not figured out how to implement the content of
    > > the
    > > custom HttpHandler, so that it first goes throuht my custom code, and then
    > > let the Page class handle the rest.
    > >
    > > Any ideas?
    > >
    > > Thanx!
    > > Paul

    >
    >
    >
     
    =?Utf-8?B?UGF1bA==?=, Jun 15, 2005
    #4
  5. I solved the problem using the PageParser.GetCompilerPageInstance() method.
    I hope there are no performence downsides or any other downsides for that
    matter using this method.

    Thanx alot!

    "Brock Allen" wrote:

    > You can try Server.Transfer to process the ASPX page. Depending upon what
    > you need to do, you could instead implement IHttpHandlerFactory and do what
    > you need to in GetHandler, then delegate to the built in PageHandlerFactory.
    > Or from your HttpHandler simply call into PageHandlerFactory to get the ASPX
    > handler then call its ProcessRequest directly.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > Hi!
    > >
    > > I want my web application to be able to handle files with the
    > > extension .mspx (my own extension). The new extension should be
    > > handled exatly the way aspx files are handled, but with some
    > > additional code specific to the .mspx extension files.
    > >
    > > I thought this would be an easy task, but maby I've cornored myself
    > > into a wrong path. I've set the mapping correct in IIS, so that
    > > asp.net manages the new extension. I've also created a class that
    > > inherits from the IHttpHandler interface. This custom HttpHandler is
    > > also registered in web.config.
    > >
    > > So far so good, but I've not figured out how to implement the content
    > > of the custom HttpHandler, so that it first goes throuht my custom
    > > code, and then let the Page class handle the rest.
    > >
    > > Any ideas?
    > >
    > > Thanx!
    > > Paul

    >
    >
    >
    >
     
    =?Utf-8?B?UGF1bA==?=, Jun 15, 2005
    #5
    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. Edwin Knoppert
    Replies:
    0
    Views:
    374
    Edwin Knoppert
    Dec 29, 2005
  2. Gerry
    Replies:
    0
    Views:
    333
    Gerry
    Feb 1, 2008
  3. Replies:
    0
    Views:
    224
  4. Paolo Elvati

    argparse and default for FileType

    Paolo Elvati, Apr 8, 2011, in forum: Python
    Replies:
    0
    Views:
    189
    Paolo Elvati
    Apr 8, 2011
  5. Replies:
    0
    Views:
    165
Loading...

Share This Page