473,568 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.InputSt ream
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.Diagnost ics.Trace.Write Line(Context.Re quest.InputStre am.CanRead); //
I get out of memory

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

Cheers

Steve
Nov 18 '05 #1
7 6412
turn page buffering off.

Page.ResponseBu fferOutput = 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******** **********@TK2M SFTNGP09.phx.gb l...
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.InputSt ream
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.Diagnost ics.Trace.Write Line(Context.Re quest.InputStre am.CanRead); // I get out of memory

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

Cheers

Steve

Nov 18 '05 #2
"Steve Drake" <Steve@_NOSPAM_ .Drakey.co.uk> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
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.InputSt ream
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******** *****@TK2MSFTNG P15.phx.gbl...
turn page buffering off.

Page.ResponseBu fferOutput = 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******** **********@TK2M SFTNGP09.phx.gb l...
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.InputSt ream
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.Diagnost ics.Trace.Write Line(Context.Re quest.InputStre am.CanRead);

//
I get out of memory

byte[] data = new byte[4096];
data = Context.Request .BinaryRead(409 6); // 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,D EBUG,OPTIONS to
GET,HEAD,POST,D EBUG,OPTIONS,PU T

Add this to the page load

private void Page_Load(objec t sender, System.EventArg s e)
{
System.IO.Strea m RequestStream;
System.Net.Http WebRequest Request =
(System.Net.Htt pWebRequest)Sys tem.Net.HttpWeb Request.Create( "http://localhos
t/LargePUTTest/test.aspx");
Request.Method = "PUT";
Request.Content Length = 1024 * 1024 * 1024;// 1 GIGish some people says
its 1024 * 1024 * 1000 :)
RequestStream = Request.GetRequ estStream();
byte[] data = new byte[4096];
for(int i=0;i<Request.C ontentLength;i+ =4096)
RequestStream.W rite(data,0,409 6);
RequestStream.C lose();
}

Add this file (name httpHandler.cs)

using System;
using System.Web;

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

public IAsyncResult BeginProcessReq uest(HttpContex t context,
System.AsyncCal lback cb, object extraData)
{
// TODO: Add httpHandlers.Be ginProcessReque st implementation
System.Diagnost ics.Trace.Write Line(context.Re quest.InputStre am.CanRead);
// this causes the out of memory.
return null;
}

public void EndProcessReque st(IAsyncResult result)
{
// TODO: Add httpHandlers.En dProcessRequest implementation
}

#endregion

#region IHttpHandler Members

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

public bool IsReusable
{
get
{
// TODO: Add httpHandlers.Is Reusable 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******** ******@TK2MSFTN GP09.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.InputSt ream
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.Diagnost ics.Trace.Write Line(Context.Re quest.InputStre am.CanRead); // I get out of memory

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

Cheers

Steve

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


Steve, what happens if your BeginProcessReq uest method just does a
inputStream.Beg inRead(...)?
--

-----
John Saunders
Nov 18 '05 #7
Steve,

I'd write an ISAPI and either do a IO Completion using HSE_REQ_IO_COMP LETION
or just use EXTENSION_CONTR OL_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******** ********@TK2MSF TNGP15.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******** ******@TK2MSFTN GP09.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.InputSt ream
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.Diagnost ics.Trace.Write Line(Context.Re quest.InputStre am.CanRead);

//
I get out of memory

byte[] data = new byte[4096];
data = Context.Request .BinaryRead(409 6); // 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
8524
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 I need an unbuffered one.
1
2760
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 InputStream which can then be passed to the FOP XSLT transformer. any ideas?
1
2107
by: Charles.Deisler | last post by:
XmlTextReader requestdata = new XmlTextReader(Request.InputStream); XmlTextWriter xmltextwriter = new XmlTextWriter(somefile,someencoding); XmlTextWriter xmltextwriter2 = new XmlTextWriter(somefile2,someencoding); xmltextwriter.WriteNode(requestdata, false); // i want to write to another writer here by resetting the reader ...
0
1730
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 works fine. To display the preview, I use a StreamReader to read the PostedFile.InputStream stream. When I later try to open the InputStream to...
1
8079
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 System.Web.HttpContext.Current.Request.Params. I would now like to get the entire:
1
4573
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 file as an inputstream as follows: import java.util.zip.ZipEntry; import java.util.zip.ZipFile; ZipFile zipFile = new ZipFile("foo.ear");
0
1227
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 understandable so chk it what should i do to convert such type of data Stream str; string strmContents= ""; int counter,...
4
36541
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 = Page.Request.Files; HttpPostedFile file = files;
11
1617
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 pull this off after the HTTP connection has already been built. Anyway, as I see it, this is more of a HTTP protocol question. I think what you...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.