Previous Next

Thread: Read Form Data from Managed HTTP Module and ASP Classic

Last post 10-08-2008 8:42 AM by RashmiPatel. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 07-16-2008, 6:31 PM

    • sranck
    • Not Ranked
    • Joined on 07-16-2008, 10:21 PM
    • Posts 2

    Read Form Data from Managed HTTP Module and ASP Classic

    I am trying to build a managed HTTP module that inspects form data before the request gets passed on to the underlying handler (ASP.NET or ASP Classic). Everything works fine when the request is for an ASP.NET page. With ASP Classic pages, however, an unspecified error (80004005) is thrown every time Request.Form is accessed.

    I suspect the problem is that the HTTP module reads all of the form data when it accesses Request.Form. Then, when ASP Classic attempts to access the form data, there is nothing left to read.

    Is there any way to read form data from a managed HTTP module and still leave it intact and readable by ASP Classic?

    Update:

    After doing a little bit of research, I attempted the following...

    Dim context As HttpContext = HttpContext.Current
    Dim provider As IServiceProvider = CType(context, IServiceProvider)
    Dim request As HttpWorkerRequest = CType(provider.GetService(GetType(HttpWorkerRequest)), HttpWorkerRequest)
    Dim buffer() As Byte = request.GetPreloadedEntityBody()

    ... operating under the assumption that I should be able to at least access the beginning of the form data. I assumed that the size of the data in GetPreloadedEntityBody would be uploadReadAheadSize (48KB) but this assumption seems to be incorrect as it always return null.

    Can anybody shed some light on this?

  • 07-21-2008, 5:00 PM In reply to

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

    Re: Read Form Data from Managed HTTP Module and ASP Classic

    The only way to pass on the POST data from a managed module is to use HttpServerUtility.TransferRequest with preserveForm=true - from a native module, you could have used IHttpRequest::InsertEntityBody

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 07-21-2008, 6:03 PM In reply to

    • sranck
    • Not Ranked
    • Joined on 07-16-2008, 10:21 PM
    • Posts 2

    Re: Read Form Data from Managed HTTP Module and ASP Classic

    Thanks Anli! I put together a quick test and HttpServerUtility.TransferRequest seems like it will do what I need.

  • 10-08-2008, 8:42 AM In reply to

    Re: Read Form Data from Managed HTTP Module and ASP Classic

     Hello Anil,

    I have implemented an Upload Control in VS 2003. I have used near to same code as Sranck had listed. Mainly used the GetPreloadedEntityBody() method. Everything works fine.

    Now i have converted that in VS 2008 + Windows XP, the control still works fine.

    But when i tried to convert the same control in VS 2008 + Vista + IIS7, the control fails to execute. The method  GetPreloadedEntityBody() always returns null.

    Can you please help me if i have to make changes in the code for IIS7?

    Thanks in advance

     

     

Page 1 of 1 (4 items)
Page view counter