473,378 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ASP.NET InputStream is not a stream

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
Nov 18 '05 #1
7 6395
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:%2******************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #2
"Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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
Nov 18 '05 #3
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" <no***********@safeco.com> wrote in message
news:#C*************@TK2MSFTNGP15.phx.gbl...
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:%2******************@TK2MSFTNGP09.phx.gbl...
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


Nov 18 '05 #4
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
}
}


Nov 18 '05 #5
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:#F**************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #6
"Steve Drake" <Steve@_NOSPAM_.Drakey.co.uk> wrote in message
news:eZ**************@TK2MSFTNGP14.phx.gbl...
I get the same problem.


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

-----
John Saunders
Nov 18 '05 #7
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:%2****************@TK2MSFTNGP15.phx.gbl...
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:#F**************@TK2MSFTNGP09.phx.gbl...
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


Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Seong Jin, Cho | last post by:
Hi. Is there a way to get an unbuffered InputStream from Process? I found out that java.lang.Win32Process and java.lang.UNIXProcess both wraps the stdout with java.io.BufferedInputStream, but...
1
by: Manoj Nair | last post by:
I am using Weblogic XMLOutoutStream to create a XML file on the fly. But instead of using flush() method and writing a physical file onto the disk I want to convert this outputstream to a java...
1
by: Charles.Deisler | last post by:
XmlTextReader requestdata = new XmlTextReader(Request.InputStream); XmlTextWriter xmltextwriter = new XmlTextWriter(somefile,someencoding); XmlTextWriter xmltextwriter2 = new...
0
by: Keith Harris | last post by:
Hi, I have an HtmlInputFile control which allows a user to upload a CSV file. I want to display the first few rows for preview and later, load the rows to a database. Displaying the preview...
1
by: samtilden | last post by:
I want to print out some tracing messages from Global.asax.cs/Application_BeginRequest(). I easily got: System.Web.HttpContext.Current.Request.RawUrl, and...
1
by: O.B. | last post by:
I have the need to read a file (version.txt) that is embedded within an WAR file that is within an EAR file: foo.ear contains bar.war contains resources/version.txt I am able to get the bar.ear...
0
by: raheel javed | last post by:
i am using mobile for communication with live server when mobile send its information to server the input stream is encoded in utf-8 that is converted into string but it is still not...
4
by: macap.usenet | last post by:
Hello, I´ve a strange problem with my HttpPostedFile object. I coded a File Upload where the user can upload a zip file. My code looks like this: HttpFileCollection files =...
11
by: John Krukoff | last post by:
-----Original Message----- First off, ignore castironpi, it's a turing test failure. Second, I'm curious as to how Java manages this. I'd think their streams would have to be pretty magic to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.