By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,117 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,117 IT Pros & Developers. It's quick & easy.

Response.Write Problem

P: n/a
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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
stringcontent = stringcontent.Substring(500);
while(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}
}
Response.Write(stringcontent);

How I can solve it?? Thx a lot.

Matthew
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}
Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.com> wrote in message
news:OY**************@TK2MSFTNGP09.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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
stringcontent = stringcontent.Substring(500);
while(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}
}
Response.Write(stringcontent);

How I can solve it?? Thx a lot.

Matthew

Nov 18 '05 #2

P: n/a
sorry, the code should be

while(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
stringcontent= stringcontent.Substring(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******@hotmail.com.nospam> wrote in message
news:#H**************@TK2MSFTNGP09.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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}


Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.com> wrote in message
news:OY**************@TK2MSFTNGP09.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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
stringcontent = stringcontent.Substring(500);
while(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}
}
Response.Write(stringcontent);

How I can solve it?? Thx a lot.

Matthew


Nov 18 '05 #3

P: n/a
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(stringcontent.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:stringcontent.Length;

Response.Write(stringcontent.Substring(0,myLength) );
Response.Write("<BR>");
stringcontent= stringcontent.Substring(myLength);
}
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.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... sorry, the code should be

while(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
stringcontent= stringcontent.Substring(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******@hotmail.com.nospam> wrote in message
news:#H**************@TK2MSFTNGP09.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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}


Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.com> wrote in message
news:OY**************@TK2MSFTNGP09.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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
stringcontent = stringcontent.Substring(500);
while(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}
}
Response.Write(stringcontent);

How I can solve it?? Thx a lot.

Matthew



Nov 18 '05 #4

P: n/a
Hello Matthew,

And what happens when you do:

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

while(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
stringcontent= stringcontent.Substring(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******@hotmail.com.nospam> wrote in message
news:#H**************@TK2MSFTNGP09.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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}

Regards
Ashish M Bhonkiya
"matthew" <ma**@sinaman.com> wrote in message
news:OY**************@TK2MSFTNGP09.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(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
stringcontent = stringcontent.Substring(500);
while(stringcontent.Length > 500)
{
Response.Write(stringcontent.Substring(0,500));
pagecontent = stringcontent.Substring(500);
}
}
Response.Write(stringcontent);
How I can solve it?? Thx a lot.

Matthew

--

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #5

P: n/a
"matthew" <ma**@sinaman.com> wrote in message
news:OY**************@TK2MSFTNGP09.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 discussion thread is closed

Replies have been disabled for this discussion.