Re: I can't get httpWorkerRequest.ReadEntityBody() to work !!!



Hi Will,

Welcome to the ASP.NET newsgroup.

From your description and the code snippet you provided, you're buiding an
ASP.NET Httpmodule to intercept file upload requests. And you use the
HttpWorkerRequest class to manipulate the http request message in
httpmodule. However , you find that some of the HttpWorkerRequest
properties and method dosn't return the expecte value and you also get some
other exceptions when try calling some certain method, correct?

Based on my experience, for ASP.NET httpmodule or handler, they're high
level components which should access the well encapsulated and implemented
class and interfaces. The HttpWorkerRequest class is a raw abstract class
which is not quite expected to directly used by our application code unless
we're developing a custom asp.net hosting application. Instead, the
HttpRequest/HttpResponse class are the concrete implemented component
classes we should use in our page or module/handler components. For file
uploading, the HttpRequest class contains the "Files" property which can
help us access the uploaded file streams in the Multi-Part form request.
e.g:

========================
public class FUloadHttpModule : IHttpModule
{
public FUloadHttpModule()
{

}

#region IHttpModule Members

public void Dispose()
{

}

public void Init(HttpApplication context)
{
context.BeginRequest +=new EventHandler(BeginRequest);


}

#endregion


protected void BeginRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
HttpContext ctx = app.Context;
HttpRequest request = ctx.Request;
HttpResponse response = ctx.Response;

if (request.RawUrl.EndsWith("upload.aspx") & request.Files.Count>0)
{
foreach (string key in request.Files.Keys)
{
response.Write("<br>" + key + ", " +
request.Files[key].ContentType);

}

response.End();

}


}
}
=====================

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


.



Relevant Pages

  • Solution design
    ... allow the end user to upload photos to the server. ... The first request would trigger for creating: ... and uses the advantages of the .NET technologies even on client side). ... we tried to create a Java applet that was trying to ...
    (microsoft.public.dotnet.general)
  • RE: Best way to monitor online user activity?
    ... HttpModule should be a good approach. ... handler that process the request. ... you can create a custom httpmodule and configure it behind ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Best way to monitor online user activity?
    ... HttpModule should be a good approach. ... handler that process the request. ... you can create a custom httpmodule and configure it behind ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Roles based Forms Auth - denied pages redirect
    ... but figured that an HttpModule would be the only possible way. ... redirect to a custom page - from which I could tell the user they are not ... >Shaun Venus ... >> have to write such code and lookup web.config files for each request (I ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: [PHP] php File upload
    ... support on the client, and a server that understands the DAV request. ... I've not had to upload such large files over HTTP, ... sends them in the response headers when serving a GET request. ...
    (php.general)