Developer forum

Forum » Development » Buffer false
Mikkel Høst
Reply

Hello.

Why won't a page run with Buffer="false" ?

And are there a way around this?

 

did my test on DW 8.1.1.7

 


Replies

 
Nicolai Høeg Pedersen
Reply

Do you get an error? And can you post it here?

 

It could be related to some of the headers we set.

 

And may I ask for what reason? Its just the buffer between .NET and IIS, disabling it makes your site slower I believe...

 

BR Nicolai

 
Mikkel Høst
Reply

The error is :

Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.

Th reason : I'm trying to make a "friendly" UI. Example, importing 1.000.000 rows takes a couple of minutes.. So i want to update the user with progress. I was trying to iframe a .aspx page with buffer=false to accomplish this and this is why i came about this.. Maybe there are a better way .NET wise to do this?.

 

 
Nicolai Høeg Pedersen
Reply

Oh, ok.

When you set a pages (asp.net page) buffer to false, it handles the buffer between the app domain and IIS.
You want to set the response buffer to false. That is the buffer between the browser and IIS.

So what you wanna do is something like this:

 

Response.Buffer = True
Response.BufferOutput = True
Response.Write(New String(" "c, 512)) 'IE will not start rendering its buffer before it received 256 characters...
Response.Flush()
Server.ScriptTimeout = 60 * 60 * 10

Base.w("1%")
Response.Flush()
Base.w("2%")
Response.Flush()
Base.w("3%")
Response.Flush()

BR Nicolai

 
Kevin Steffer
Reply

Maybe SignalR would be a good match for your situation read more here http://signalr.net/

 
Mikkel Høst
Reply

Hi Nicolai.

I'm no expert here but i think what you are saying is a bit wrong. When you set "Buffer=false" in the page directive (directly in the .aspx page) - it will set the bufferoutput to false and hence write the output as it executes, this is what i want to accomplish. I can do that with the code you provided (where i set the buffer to false instead of true as you wrote) but that will result in the same result, the unknown error.

you can easily reproduce this, just create a standard web form (aspx) page, set the buffer=false in page directive OR in the code like

Response.Buffer = False
Response.BufferOutput = False

 

And execute that page on a DW website.  

 

 
Nicolai Høeg Pedersen
Reply

You are right - BufferOutput is set by the page directive.

 

The code snippet is from some code in DW, so I've tried that.

 

Made an example here:

http://developer.dynamicweb-cms.com/buffer.aspx

 

See the code here, also attached.

 

<%
	System.Web.HttpContext.Current.Response.BufferOutput = True
	System.Web.HttpContext.Current.Response.Write(New String(" "c, 512)) 'IE will not start rendering its buffer before it received 256 characters...
	System.Web.HttpContext.Current.Response.Flush()
	System.Web.HttpContext.Current.Server.ScriptTimeout = 60 * 60 * 10

	%>
<!DOCTYPE html>
<html>
<head>
	<title>Buffer test</title>
</head>
<body>
	<h1>Buffering</h1>
	<span id="perc">Starting</span>
	
	
		<%
 
		For i As Integer = 1 To 100
				System.Web.HttpContext.Current.Response.Write("<script>document.getElementById('perc').innerHTML = '" & i & "%';</script>" & Environment.NewLine)
				System.Threading.Thread.Sleep(100)
			System.Web.HttpContext.Current.Response.Flush()
			
		Next
 %>
	<div>done...</div>
</body>
</html>

 

 
Mikkel Høst
Reply

Try setting 

System.Web.HttpContext.Current.Response.BufferOutput = False

 

 
Nicolai Høeg Pedersen
Reply

Oh, great - my bad.

 

Did that now.

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

What about spinning up a background worker (or some other thread) and do polling against that?

 

- Jeppe

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Not really the answer to the question on buffering, but it might be the answer to the problem: why not simply use a web service for this? Here's what I would so:

 

1. In your import routine, update a session variable with the progress. It all runs in the backend, so session is available

2. Write a Web Service (with session state enabled) that returns the progress

3. Write 6 lines of jQuery code that calls this web service every X seconds and updates the label.

 

I've used this a lot in the past and it works really well.

 

Cheers,

 

Imar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Firefox now says this:

 

>> The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

 

Would excluding the file / folder from the HttpCompression module solve the problem?

Imar

 
Nicolai Høeg Pedersen
Reply

@Imar

I have it working in all major browsers, FF, IE, Chrome, Safari...

 

But it could be related to http compression, so trying to disable httpcompression could help.

 

//Nicolai

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> I have it working in all major browsers,

 

On http://developer.dynamicweb-cms.com/buffer.aspx ? Interesting. That errors for me on all major browsers. Opera has the most useful information (see attached).

 

Imar

4-17-2013_12-30-18_PM.png
 
Mikkel Høst
Reply

Same here as Imar.

And Imar i really like the webservice + session idea! Thanks for the input.

 

 

Capture.PNG

 

You must be logged in to post in the forum