Re: I can't get httpWorkerRequest.ReadEntityBody() to work !!!
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Fri, 03 Feb 2006 07:52:15 GMT
Hi Will,
Welcome to the ASP.NET newsgroup.
From your description and the code snippet you provided, you're buiding anASP.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.)
.
- References:
- I can't get httpWorkerRequest.ReadEntityBody() to work !!!
- From: madhattan
- Re: I can't get httpWorkerRequest.ReadEntityBody() to work !!!
- From: madhattan
- I can't get httpWorkerRequest.ReadEntityBody() to work !!!
- Prev by Date: Re: ASP Ajax __VIEWSTATE = BAD ?
- Next by Date: RE: I can't add a Web Reference
- Previous by thread: Re: I can't get httpWorkerRequest.ReadEntityBody() to work !!!
- Next by thread: Re: c# reference manual
- Index(es):
Relevant Pages
|