Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default HttpModule

    Is it possible to capture a request as it hits the server and before the
    post data has been completely sent to the web server?

    Thanks~


    PJ Guest

  2. Similar Questions and Discussions

    1. HttpModule Multithreading and instances
      I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am...
    2. Authentication using HttpModule
      I know that we can perform authentication of .aspx pages with an HttpModule, and that the same module can probably be used for static content (.htm,...
    3. HttpModule & Basic Auth
      I'll try asking this another way What I'm after is 1) IIS configuration for anonymous access ONLY (NO Basic Authentication) 2) Client sends...
    4. Interceptor, HttpModule, WSE
      I've developed a framework for ASP.NET with a custom authentication module (HttpModule). This module is already working. This framework should also...
    5. HttpModule for ASP and ASP.NET URL filtering
      I'm interested in writing an HttpModule to clean up URLs for a site that's in a transitional phase from ASP to ASP.NET. Basically, I'd like to hide...
  3. #2

    Default Re: HttpModule

    I've never done it, but you should be able to inspect the incoming stream vi
    the request.filter. If you look in the HTTPModules section on [url]www.asp.net[/url]
    their is a long thread on uploading large files which covers this to some
    degree.

    --
    Regards

    John Timney (Microsoft ASP.NET MVP)
    ----------------------------------------------
    <shameless_author_plug>
    Professional .NET for Java Developers with C#
    ISBN:1-861007-91-4
    Professional Windows Forms
    ISBN: 1861005547
    Professional JSP 2nd Edition
    ISBN: 1861004958
    Professional JSP
    ISBN: 1861003625
    Beginning JSP Web Development
    ISBN: 1861002092
    </shameless_author_plug>
    ----------------------------------------------

    "PJ" <pjwal@hotmail.com> wrote in message
    news:e4ojrNITDHA.2768@tk2msftngp13.phx.gbl...
    > Is it possible to capture a request as it hits the server and before the
    > post data has been completely sent to the web server?
    >
    > Thanks~
    >
    >

    John Timney \(Microsoft MVP\) Guest

  4. #3

    Default Re: HttpModule

    I'm am looking for the posted contents as they come into the server, but
    (IMPORTANTLY) before they have been completely sent. Specifically, I need
    to let users upload ~ 1gb files so I need to grab the posted file bytes as
    they are streaming into the server and save it to disk.

    Can I do this by wiring an event to the BeginRequest in the Init event of a
    module? Will the code below work? If so, how do I ensure that all of the
    posted file bytes do not go into memory? Will the act of reading the bytes
    ensure that the bytes do not go into memory as the request is sent on to the
    page handler?

    'sorry for the vb, forced to use this language
    Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init
    AddHandler app.BeginRequest, New EventHandler(AddressOf
    Me.OnBeginRequest)
    End Sub

    Public Sub OnBeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    Dim ctx As HttpContext = CType(sender, HttpApplication).Context
    If ctx.Request.Files.Count > 0 Then
    Dim fs As New FileStream(Path.Combine("c:\uploads",
    Path.GetFileName(ctx.Request.Files(0).FileName)), FileMode.Create)
    Dim br As New BinaryReader(ctx.Request.Files(0).InputStream)
    Dim bw As New BinaryWriter(fs)
    Dim size As Integer = 1024
    Dim position As Integer
    Do
    If position + size > br.BaseStream.Length Then
    size = Convert.ToInt32(br.BaseStream.Length) - position
    End If
    bw.Write(br.ReadBytes(size))
    position += size
    Loop Until position >= ctx.Request.Files(0).ContentLength
    bw.Close()
    br.Close()
    fs.Close()
    End If
    End Sub

    "Sreejumon[MVP]" <sreeju_uss@hotmail.com> wrote in message
    news:031b01c34c9f$7cfcd000$a401280a@phx.gbl...
    > Hi,
    >
    > Are you looking for the page header or request contents?
    >
    > If youa re looking for request contents, then you can save
    > the request stream to file using SaveAs method of
    > HttpRequest class. If you need header specify the second
    > parameter of saveas fucntion.
    >
    > Similay you can use the HTTPRespose obejcts method to
    > write the responze to file.
    >
    >
    > Let me know if you need further help.
    > regards
    > Sreejumon
    >
    >
    > >-----Original Message-----
    > >Is it possible to capture a request as it hits the server
    > and before the
    > >post data has been completely sent to the web server?
    > >
    > >Thanks~
    > >
    > >
    > >.
    > >

    PJ Guest

  5. #4

    Default Re: HttpModule

    Check out this article,
    [url]http://www.microsoft.com/india/msdn/articles/HTTPHandlersandHTTPModulesinASP[/url]
    ..aspx

    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "PJ" <pjwal@hotmail.com> wrote in message
    news:e4ojrNITDHA.2768@tk2msftngp13.phx.gbl...
    > Is it possible to capture a request as it hits the server and before the
    > post data has been completely sent to the web server?
    >
    > Thanks~
    >
    >

    Saravana Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139