473,796 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Response.Write Problem

Hi all,

I am now writing a aspx that get a session variable (string) and then write
it out using Response.Write.

The string length is: 494710.

But Response.Write only write the string partially!

I tried using following code, but it doesn't work, the page is keep loading.

if(stringconten t.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
stringcontent = stringcontent.S ubstring(500);
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}
}
Response.Write( stringcontent);

How I can solve it?? Thx a lot.

Matthew
Nov 18 '05 #1
5 2112
Hi matthew,

you should not be storing huge items in session as this can degrade your
performance.

if i see your code it seems like you are not changing the value of
stringcontent variable so its an infinite loop.
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}
Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.c om> wrote in message
news:OY******** ******@TK2MSFTN GP09.phx.gbl... Hi all,

I am now writing a aspx that get a session variable (string) and then write it out using Response.Write.

The string length is: 494710.

But Response.Write only write the string partially!

I tried using following code, but it doesn't work, the page is keep loading.
if(stringconten t.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
stringcontent = stringcontent.S ubstring(500);
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}
}
Response.Write( stringcontent);

How I can solve it?? Thx a lot.

Matthew

Nov 18 '05 #2
sorry, the code should be

while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
stringcontent= stringcontent.S ubstring(500);
}

still doesn't work.

If i don't use session, how i can pass such item from aspx to other aspx?
"Ashish M Bhonkiya" <bh******@hotma il.com.nospam> wrote in message
news:#H******** ******@TK2MSFTN GP09.phx.gbl...
Hi matthew,

you should not be storing huge items in session as this can degrade your
performance.

if i see your code it seems like you are not changing the value of
stringcontent variable so its an infinite loop.
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}


Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.c om> wrote in message
news:OY******** ******@TK2MSFTN GP09.phx.gbl...
Hi all,

I am now writing a aspx that get a session variable (string) and then

write
it out using Response.Write.

The string length is: 494710.

But Response.Write only write the string partially!

I tried using following code, but it doesn't work, the page is keep

loading.

if(stringconten t.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
stringcontent = stringcontent.S ubstring(500);
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}
}
Response.Write( stringcontent);

How I can solve it?? Thx a lot.

Matthew


Nov 18 '05 #3
Hi Matthew,

Probably if you use your code it will not display the last part and that is
where the problem is. so you may update your code as follows and it should
work.

while(stringcon tent.Length > 0)
{
// this will take care of the length at the last part if it
is not in the multuple of 500.
int myLength = (stringcontent. Length>500) ?
500:stringconte nt.Length;

Response.Write( stringcontent.S ubstring(0,myLe ngth));
Response.Write( "<BR>");
stringcontent= stringcontent.S ubstring(myLeng th);
}
If i don't use session, how i can pass such item from aspx to other aspx?

it was just to make you aware to not unnecessacarily load the server
resources you may go for session variables no issues.
Also you can the data across the form using Using Querystring or Using
Server.Transfer you may read this article for more details
http://www.dotnetbips.com/displayarticle.aspx?id=79

HTH
Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.c om> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. sorry, the code should be

while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
stringcontent= stringcontent.S ubstring(500);
}

still doesn't work.

If i don't use session, how i can pass such item from aspx to other aspx?
"Ashish M Bhonkiya" <bh******@hotma il.com.nospam> wrote in message
news:#H******** ******@TK2MSFTN GP09.phx.gbl...
Hi matthew,

you should not be storing huge items in session as this can degrade your
performance.

if i see your code it seems like you are not changing the value of
stringcontent variable so its an infinite loop.
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}


Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.c om> wrote in message
news:OY******** ******@TK2MSFTN GP09.phx.gbl...
Hi all,

I am now writing a aspx that get a session variable (string) and then

write
it out using Response.Write.

The string length is: 494710.

But Response.Write only write the string partially!

I tried using following code, but it doesn't work, the page is keep

loading.

if(stringconten t.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
stringcontent = stringcontent.S ubstring(500);
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}
}
Response.Write( stringcontent);

How I can solve it?? Thx a lot.

Matthew



Nov 18 '05 #4
Hello Matthew,

And what happens when you do:

Response.Write( stringcontent);
Response.Flush( );
sorry, the code should be

while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
stringcontent= stringcontent.S ubstring(500);
}
still doesn't work.

If i don't use session, how i can pass such item from aspx to other
aspx?

"Ashish M Bhonkiya" <bh******@hotma il.com.nospam> wrote in message
news:#H******** ******@TK2MSFTN GP09.phx.gbl...
Hi matthew,

you should not be storing huge items in session as this can degrade
your performance.

if i see your code it seems like you are not changing the value of
stringcontent variable so its an infinite loop.
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}

Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.c om> wrote in message
news:OY******** ******@TK2MSFTN GP09.phx.gbl...
Hi all,

I am now writing a aspx that get a session variable (string) and
then

write
it out using Response.Write.

The string length is: 494710.

But Response.Write only write the string partially!

I tried using following code, but it doesn't work, the page is keep

loading.
if(stringconten t.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
stringcontent = stringcontent.S ubstring(500);
while(stringcon tent.Length > 500)
{
Response.Write( stringcontent.S ubstring(0,500) );
pagecontent = stringcontent.S ubstring(500);
}
}
Response.Write( stringcontent);
How I can solve it?? Thx a lot.

Matthew

--

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #5
"matthew" <ma**@sinaman.c om> wrote in message
news:OY******** ******@TK2MSFTN GP09.phx.gbl...
I am now writing a aspx that get a session variable (string) and then write it out using Response.Write. .. . . But Response.Write only write the string partially!


matthew,

Does it "break" at any "meaningful " point or just give up after a
certain number of bytes or at a given character in the data (say,
a null character, 0x00 )?

HTH,
Phill W.
Nov 18 '05 #6

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

Similar topics

3
2827
by: Gary | last post by:
I am having a strange problem that I cannot solve. I have an asp page that I use for a user to login and gain access to other pages. When the user logs in I set a couple of session variables like Session("UserType") = "Sales". Then based on the Session("UserType") I use response.redirect to take the user to a specific page. The logic and response.redirect works fine on a Win2k server but when I move the page to a server running Win2003 the...
8
2602
by: Jack | last post by:
Hi, Here is my problem: I am logging in to a page, where the page retrieves a record from a database. The text boxes are used in the display formto let the users update the fields, if they desire to. The colorpreference and foodpreference fields are text fields while the FinalUpdate field is a yes/no field in Access Database.
6
3060
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a cookie (say Response.Cookies ("TEST")) and you have a query string variable &test=x or &Test=x and you get Request.QueryString to parse the query string, the cookie that gets dropped matches the case of the query string, not what your code says. ...
9
6340
by: msuk | last post by:
All, I have a well form block of XML that is stored in a C# string type and I just simply want to display it in the browser using Response.Write but when I try this I get the following error: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
3
2479
by: Brad | last post by:
I have a response filter which injects "standard" html into my pages. The filter works fine when the initial stream is small enough not to buffer...or....if I have a large unbuffered stream (i.e. I set buffer=false on a large page). Now the problem: If I turn on buffering on a large page, the page output (to the browser) is correct a few times (sometines just once, sometime 2-3 times...on the same page) then I seem to either lose data...
11
26901
by: Russ | last post by:
My web app writes some binary data to a file at the client site via Response.Write and Response.BinaryWrite. This action is accomplished in response to a button click, with C# code behind as follows: private void SubmitButton_Click (object sender, System.EventArgs e) { // Set up the response to write the print file to the client Response.Clear (); Response.AppendHeader ("Content-Disposition", "filename=WebPrint.prn");
17
1785
by: raj chahal | last post by:
Hi there I need to be able to print on screen when I check if a value within a db <td> <% if ((Recordset1.Fields.Item("profile1").Value) <> "") then response.Write"Pro1<br>" & Recordset1.Fields.Item("profile1").Value%> </td>
12
7918
by: Jim Rodgers | last post by:
I have a big asp file that has an error under certain conditions -- totally repeatable. However, it only fails when I set response.buffer = True at the top. WHen I set it False in order to debug it, it works every time! I even set it to True, but did a .Flush just before the error, and the error won't happen. It only happens when response.buffer is True and no .response.flush is issued. The error is a string variable turns-up empty...
7
3316
by: Jim in Arizona | last post by:
I'm brand new at ajax. In fact, about 20 minutes ago was the first time I got it to work. The problem I'm having on another page did not work, however. I'm running into the following error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server...
0
10223
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.