« Previous Next »

Answered Thread: How to stop IIS 7 from blocking/stomping-on the response body generated by an ISAPI Filter

Last post 10-19-2007 3:14 PM by anilr. 6 replies.

 

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 10-18-2007, 12:24 PM

    • mcgintym
    • Not Ranked
    • Joined on 10-18-2007, 4:21 PM
    • Posts 5

    How to stop IIS 7 from blocking/stomping-on the response body generated by an ISAPI Filter

    I've installed ServletExec 6.0b1 into my IIS 7 (on Win 2008 RC0).
    It works fine and I am able to request simple Servlets and JSPs.
    The issue I have is when I request a JSP which returns a 500 status code (on purpose) with a custom response body. In this case the custom response body is configured inside ServletExec (the Servlet/JSP engine which is "hooked into" IIS as an ISAPI Filter... not as an HttpModule).

    I want to see that custom response body.
    But instead IIS 7 is being fancy and "stomping on" my custom response body.

    IIS 7 is returning a preconfigured 500 response body.
    I removed the error page mapping for the 500 status code (did this in the IIS Manager) for my IIS website. But while doing that *did* change the behavior slightly, it did not fix the issue.

    Now when I request my JSP, IIS 7 returns this response body:

    The page cannot be displayed because an internal server error has occurred.


    Now... I know and expect that an internal server error occurred (remember that my JSP sets the status code to 500 on purpose). So I actually want an error to "occur". But I want to see the response body that my JSP built... not the response body that IIS 7 "inserts".

    I've also removed the IIS 7 error page mapping for the 500 status code at the "global" level of IIS (not just the level of my specific IIS website) but that did not have any effect.

    Can you help me?

  • 10-18-2007, 2:28 PM In reply to

    • mvolo
    • Top 25 Contributor
    • Joined on 09-17-2003, 1:48 PM
    • Philadelphia, PA
    • Posts 586
    • IIS MVPs

    Re: How to stop IIS 7 from blocking/stomping-on the response body generated by an ISAPI Filter

    IIS7 contains a custom errors feature that censors detailed error output unless the component indicates that it should not be censored (which ServletExec does not since it was written for IIS6).  You can disable this behavior in configuration for a set of urls served by this component, and thereby allow it to return detailed error messages.

    For more info, see: http://www.iis.net/articles/view.aspx/IIS7/Managing-IIS7/Diagnostics-in-IIS7/Deciphering-Error-Messages/How-to-Use-HTTP-Detailed-Errors-in-IIS7.

    Thanks,

    Mike Volodarsky

    Program Manager
    IIS Core Server
    Visit mvolo.com for more inside information on IIS7, IIS and ASP.NET

     

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 10-18-2007, 2:35 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: How to stop IIS 7 from blocking/stomping-on the response body generated by an ISAPI Filter

    In particular, you want to set

    %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/httpErrors -existingResponse:PassThrough

     

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 10-18-2007, 3:12 PM In reply to

    • mcgintym
    • Not Ranked
    • Joined on 10-18-2007, 4:21 PM
    • Posts 5

    Re: How to stop IIS 7 from blocking/stomping-on the response body generated by an ISAPI Filter

    Thanks Mike.

    I read the 3-page article at the link you gave.
    But that article seems only to talk about how to use either "Custom" or "Detailed" IIS error pages (both of which are defined in IIS). I don't want to use either. (maybe I missed something there??)

    You are correct that ServletExec (5.x) supports IIS 6 and does not support IIS 7. 
    However, I am developing ServletExec 6.0 (I am a Software Engineer for New Atlanta Communications... the makers of ServletExec). Your last reply seems to suggest that an ISAPI Filter can programmatically indicate to IIS 7 that IIS 7 should *not* censor it.

    If that's true I think that would be preferable to having to tell our customers to flip switches in IIS 7 for this.
    Especially since it sounds like it could only be done for a "set of urls served by this component" (which could be practically anything and everything).

    So can you provide any insight as to what sort of ISAPI callback I'd need to add in ServletExec's ISAPI Filter in order to do that (if it is indeed even possible)?

    If not, please provide a bit more detail as to exactly how one would "disable this behaior in configuration for a set of urls...".

    Ideally I'd like to specify a wildcard for the "set of urls" something like /* so that every single request handled by the SE ISAPI Filter would not be censored by IIS 7.

     

    Thanks in advance for any input you can provide.

     

    Matt McGinty

     

  • 10-19-2007, 12:29 AM In reply to

    • mvolo
    • Top 25 Contributor
    • Joined on 09-17-2003, 1:48 PM
    • Philadelphia, PA
    • Posts 586
    • IIS MVPs

    Answered Re: How to stop IIS 7 from blocking/stomping-on the response body generated by an ISAPI Filter

    Hi Matt,

    Use the command Anil gives above to allow third party error messages to be uncensored by default on your entire server.

    I would generally recommend against doing that for the entire server, and try to scope it only to the site/directory where your component is running.  You can do this by modifying that command to specify the path to the site/app/vdir/url at which you want to allow this:

    > %windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/" -section:system.webServer/httpErrors -existingResponse:PassThrough

    (in this example I am doing this for the "Default Web Site/")

    If you have access to the ISAPI extension source code, you can use:

    1) Flag for for HSE_REQ_VECTOR_SEND:

    #define TRY_SKIP_IIS_CUSTOM_ERRORS                        0x40 

    2) Flag for For HSE_REQ_EXEC_URL:

    #define HSE_EXEC_URL_DISABLE_CUSTOM_ERROR           0x20


    Thanks,

    Mike Volodarsky

    Program Manager
    IIS Core Server
    Visit mvolo.com for more inside information on IIS7, IIS and ASP.NET

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 10-19-2007, 10:14 AM In reply to

    • mcgintym
    • Not Ranked
    • Joined on 10-18-2007, 4:21 PM
    • Posts 5

    Re: How to stop IIS 7 from blocking/stomping-on the response body generated by an ISAPI Filter

    Thanks Mike.

    But the ServletExec ISAPI Extension uses the WriteClient ISAPI callback to write data to the client (so that it can support IIS 5.1). So do you know if there is way to do this when using WriteClient?

     Thanks.

     

    Matt
     

  • 10-19-2007, 3:14 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 10:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: How to stop IIS 7 from blocking/stomping-on the response body generated by an ISAPI Filter

    No, this flag is only supported from HSE_REQ_VECTOR_SEND - you can add logic to your code to use different API when running on different version of IIS (you can get that from pEcb->dwVersion.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
Page 1 of 1 (7 items)