all groups > dotnet web services > february 2007 >
You're in the

dotnet web services

group:

request size?


request size? chandy NO[at]SPAM totalise.co.uk
2/28/2007 3:02:00 AM
dotnet web services: Hi all,

I want to evaluate the size of the http request sent to my
webservice. How can I accomplish this?
System.Web.HttpContext.Current.Request seems to return the http
request for the browser on the aspx page that the service is called
from, not the call to the service itself.

Any ideas?

Chandy
Re: request size? Mariano Omar Rodriguez
3/7/2007 6:12:14 PM
Paste the following code in your Global.asax file

protected void Application_BeginRequest(Object sender, EventArgs e)
{
Request.InputStream.Position = 0;
byte[] buffer = new byte[Request.InputStream.Length];
Request.InputStream.Read(buffer, 0, buffer.Length);
Request.InputStream.Position = 0;

FileStream fs = File.Open("c:\\Projects\\Log.txt", FileMode.Append);
foreach (string key in Request.Headers)
{
string header = key + ": " + Request.Headers[key] + Environment.NewLine;
fs.Write(Encoding.UTF8.GetBytes(header), 0, header.Length);
}
fs.Write(buffer, 0, buffer.Length);
string end = Environment.NewLine + Environment.NewLine;
fs.Write(Encoding.UTF8.GetBytes(end), 0, end.Length);
fs.Close();
}

[quoted text, click to view]
AddThis Social Bookmark Button