Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET InputStream is not a stream

Reply
Thread Tools

ASP.NET InputStream is not a stream

 
 
Steve Drake
Guest
Posts: n/a
 
      10-13-2004
All,

I have a HttpHandler that handles a PUT, if i PUT 700MEGs of data it runs
out of memory, i have found that this is due to the Request.InputStream
loading the entire stream when you access it.

If I run any of the following i get the error :

Context.Request.SaveAs(@"C:\1.xxx",false); // I get out of memory

System.Diagnostics.Trace.WriteLine(Context.Request .InputStream.CanRead); //
I get out of memory

byte[] data = new byte[4096];
data = Context.Request.BinaryRead(4096); // I get out of memory

Cheers

Steve


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      10-13-2004
turn page buffering off.

Page.ResponseBufferOutput = false;

note: this will tie up an asp.net thread, and 2 communication threads until
completed. if you have many concurrent downloads you will quickly get a
server busy error.


-- bruce (sqlwork.com)



"Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
news:%23FjT%(E-Mail Removed)...
> All,
>
> I have a HttpHandler that handles a PUT, if i PUT 700MEGs of data it runs
> out of memory, i have found that this is due to the Request.InputStream
> loading the entire stream when you access it.
>
> If I run any of the following i get the error :
>
> Context.Request.SaveAs(@"C:\1.xxx",false); // I get out of memory
>
> System.Diagnostics.Trace.WriteLine(Context.Request .InputStream.CanRead);

//
> I get out of memory
>
> byte[] data = new byte[4096];
> data = Context.Request.BinaryRead(4096); // I get out of memory
>
> Cheers
>
> Steve
>
>



 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      10-13-2004
"Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
news:%23FjT%(E-Mail Removed)...
> All,
>
> I have a HttpHandler that handles a PUT, if i PUT 700MEGs of data it runs
> out of memory, i have found that this is due to the Request.InputStream
> loading the entire stream when you access it.


Write an asynchronous handler.
--

-----
John Saunders


 
Reply With Quote
 
Steve Drake
Guest
Posts: n/a
 
      10-14-2004
the request stream does not have the options of turning off this buffer.

but... i did try to see if it affected the request stream, and it still runs
out of memory.

Steve


"bruce barker" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> turn page buffering off.
>
> Page.ResponseBufferOutput = false;
>
> note: this will tie up an asp.net thread, and 2 communication threads

until
> completed. if you have many concurrent downloads you will quickly get a
> server busy error.
>
>
> -- bruce (sqlwork.com)
>
>
>
> "Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
> news:%23FjT%(E-Mail Removed)...
> > All,
> >
> > I have a HttpHandler that handles a PUT, if i PUT 700MEGs of data it

runs
> > out of memory, i have found that this is due to the Request.InputStream
> > loading the entire stream when you access it.
> >
> > If I run any of the following i get the error :
> >
> > Context.Request.SaveAs(@"C:\1.xxx",false); // I get out of memory
> >
> > System.Diagnostics.Trace.WriteLine(Context.Request .InputStream.CanRead);

> //
> > I get out of memory
> >
> > byte[] data = new byte[4096];
> > data = Context.Request.BinaryRead(4096); // I get out of memory
> >
> > Cheers
> >
> > Steve
> >
> >

>
>



 
Reply With Quote
 
Steve Drake
Guest
Posts: n/a
 
      10-14-2004
I get the same problem.

I have managed to reproduce this in a test app create a web project , call
it LargePUTTEST

I've done it with a async class but the real app is not. I don't think this
will matter.

Confgure IIS

Add VERB PUT to ASPX (Right click on APP in IIS, click configure, select
..ASPX, add put to list of verbs, eg change GET,HEAD,POST,DEBUG,OPTIONS to
GET,HEAD,POST,DEBUG,OPTIONS,PUT



Add this to the page load

private void Page_Load(object sender, System.EventArgs e)
{
System.IO.Stream RequestStream;
System.Net.HttpWebRequest Request =
(System.Net.HttpWebRequest)System.Net.HttpWebReque st.Create("http://localhos
t/LargePUTTest/test.aspx");
Request.Method = "PUT";
Request.ContentLength = 1024 * 1024 * 1024;// 1 GIGish some people says
its 1024 * 1024 * 1000
RequestStream = Request.GetRequestStream();
byte[] data = new byte[4096];
for(int i=0;i<Request.ContentLength;i+=4096)
RequestStream.Write(data,0,4096);
RequestStream.Close();
}

Add this file (name httpHandler.cs)

using System;
using System.Web;

namespace LargePUTTest
{
/// <summary>
/// Summary description for httpHandlers.
/// </summary>
public class httpHandler :IHttpAsyncHandler
{
public httpHandler()
{
//
// TODO: Add constructor logic here
//
}
#region IHttpAsyncHandler Members

public IAsyncResult BeginProcessRequest(HttpContext context,
System.AsyncCallback cb, object extraData)
{
// TODO: Add httpHandlers.BeginProcessRequest implementation
System.Diagnostics.Trace.WriteLine(context.Request .InputStream.CanRead);
// this causes the out of memory.
return null;
}

public void EndProcessRequest(IAsyncResult result)
{
// TODO: Add httpHandlers.EndProcessRequest implementation
}

#endregion

#region IHttpHandler Members

public void ProcessRequest(HttpContext context)
{
// TODO: Add httpHandlers.ProcessRequest implementation
}

public bool IsReusable
{
get
{
// TODO: Add httpHandlers.IsReusable getter implementation
return false;
}
}

#endregion
}
}




 
Reply With Quote
 
Steve Drake
Guest
Posts: n/a
 
      10-14-2004
I have logged this as a support call, and MS says that it copies the Request
stream into memory so you will get out of memory exceptions and there is now
way round it.

I consider this poor design.

Steve


"Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
news:#FjT#(E-Mail Removed)...
> All,
>
> I have a HttpHandler that handles a PUT, if i PUT 700MEGs of data it runs
> out of memory, i have found that this is due to the Request.InputStream
> loading the entire stream when you access it.
>
> If I run any of the following i get the error :
>
> Context.Request.SaveAs(@"C:\1.xxx",false); // I get out of memory
>
> System.Diagnostics.Trace.WriteLine(Context.Request .InputStream.CanRead);

//
> I get out of memory
>
> byte[] data = new byte[4096];
> data = Context.Request.BinaryRead(4096); // I get out of memory
>
> Cheers
>
> Steve
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      10-14-2004
"Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
news:(E-Mail Removed)...
>I get the same problem.


Steve, what happens if your BeginProcessRequest method just does a
inputStream.BeginRead(...)?
--

-----
John Saunders


 
Reply With Quote
 
Gabe Garza
Guest
Posts: n/a
 
      10-18-2004
Steve,

I'd write an ISAPI and either do a IO Completion using HSE_REQ_IO_COMPLETION
or just use EXTENSION_CONTROL_BLOCK *pEcb->ReadClient() to keep reading data
coming from the client until your 700 Meg file has been uploaded.

This will get you what you want, a stream.

Gabe

"Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
news:%(E-Mail Removed)...
> I have logged this as a support call, and MS says that it copies the

Request
> stream into memory so you will get out of memory exceptions and there is

now
> way round it.
>
> I consider this poor design.
>
> Steve
>
>
> "Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
> news:#FjT#(E-Mail Removed)...
> > All,
> >
> > I have a HttpHandler that handles a PUT, if i PUT 700MEGs of data it

runs
> > out of memory, i have found that this is due to the Request.InputStream
> > loading the entire stream when you access it.
> >
> > If I run any of the following i get the error :
> >
> > Context.Request.SaveAs(@"C:\1.xxx",false); // I get out of memory
> >
> > System.Diagnostics.Trace.WriteLine(Context.Request .InputStream.CanRead);

> //
> > I get out of memory
> >
> > byte[] data = new byte[4096];
> > data = Context.Request.BinaryRead(4096); // I get out of memory
> >
> > Cheers
> >
> > Steve
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the different between byte stream and character stream? dolphin Java 6 03-18-2007 01:58 PM
get stream mode flags from an opened stream Alexander Korsunsky C++ 1 02-17-2007 10:38 AM
How to GET multi-word input from a *file* stream as opposed to a *console* stream? sherifffruitfly@gmail.com C++ 9 04-27-2006 04:14 PM
confused: Socket InputStream != ServerSocker InputStream R Java 5 03-13-2005 07:26 AM
Doing readline in a thread from a popen4('rsync ...') stream blocks when the stream ends. Rasmusson, Lars Python 1 04-30-2004 08:10 AM



Advertisments