Have any idea what might cause this HttpException error?


A

AAaron123

Have any idea what might cause this error?

---Page loads and I click a button and the following runs:

Protected Sub ButtonDisplay_Click...
Dim objRequest As WebRequest =
System.Net.HttpWebRequest.Create(TextBox1.Text)
objRequest.Method = WebRequestMethods.Http.Get
Dim objResponse As WebResponse = objRequest.GetResponse()
Dim sr As New StreamReader(objResponse.GetResponseStream())
strResult = sr.ReadToEnd()
objResponse.Close()
sr.Close()
....

---I click the button again and the following happens:
Page_PreInit1
---Runs
End Sub
Page_InitComplete
---Runs
End sub
----Error Happens here----
Page_PreLoad


The state information is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The state information is
invalid for this page and might be corrupted.


---TextBox1.Text points to my web site
---I'm running in the IDE vs 2008


Thanks for any suggestions on how to track this down
 
Ad

Advertisements

A

AAaron123

AAaron123 said:
Have any idea what might cause this error?

---Page loads and I click a button and the following runs:

Protected Sub ButtonDisplay_Click...
Dim objRequest As WebRequest =
System.Net.HttpWebRequest.Create(TextBox1.Text)
objRequest.Method = WebRequestMethods.Http.Get
Dim objResponse As WebResponse = objRequest.GetResponse()
Dim sr As New StreamReader(objResponse.GetResponseStream())
strResult = sr.ReadToEnd()
objResponse.Close()
sr.Close()
...

---I click the button again and the following happens:
Page_PreInit1
---Runs
End Sub
Page_InitComplete
---Runs
End sub
----Error Happens here----
Page_PreLoad


The state information is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The state information is
invalid for this page and might be corrupted.


---TextBox1.Text points to my web site
---I'm running in the IDE vs 2008


Thanks for any suggestions on how to track this down

I don't know if this means anything to anybody but,

If when the error page is showing I go back one page and click again I get
the error again.

But if I go back two pages and click it works OK but another click produces
the error.

That is, if I return to where I started it works as it did the first time.

I thought that going back to a page things (like the cache) might be in a
different state the mormnnly going to a page.

I also tried it in firefox with the same error.
 
L

Leon

I don't know if this means anything to anybody but,

If when the error page is showing I go back one page and click again I get
the error again.

But if I go back two pages and click it works OK but another click produces
the error.

That is, if I return to where I started it works as it did the first time.

I thought that going back to a page things (like the cache) might be in a
different state the mormnnly going to a page.

I also tried it in firefox with the same error.
I don't know what you are trying to do in ButtonDisplay_Click, but
altering the WebRequests and Responses from code isn't really "best
practise" and can be rather tricky.
I'd say, try to rewrite the function (or comment it) and try to run it
again

..L.
 
A

AAaron123

Leon said:
I don't know what you are trying to do in ButtonDisplay_Click, but
altering the WebRequests and Responses from code isn't really "best
practise" and can be rather tricky.
I'd say, try to rewrite the function (or comment it) and try to run it
again

.L.

It's definetly due to that code.
All I'm doing is getting a copy of the html that my site sends, and
displaying it.

thanks


Here is the entire error.
I noticed the version at the end shows as 2.0 rather than 3.5
Who's framework is it refering to, me or the server?
Probably no one knows how to solve this because there are over 6000 google
hits with no answer that I could find.
I just wish I knew what the error means!
I.e., what data is in the "State Information"


Thanls



Server Error in '/St. Louis Gonzaga' Application.
--------------------------------------------------------------------------------

The state information is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The state information is
invalid for this page and might be corrupted.

Source Error:

The source code that generated this unhandled exception can only be
shown when compiled in debug mode. To enable this, please follow one of the
below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated
the error. Example:

<%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your
application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

Note that this second technique will cause all files within a given
application to be compiled in debug mode. The first technique will cause
only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a
memory/performance overhead. You should make sure that an application has
debugging disabled before deploying into production scenario.

Stack Trace:

[FormatException: Invalid character in a Base-64 string.]
System.Convert.FromBase64String(String s) +0
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +72
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String
serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter,
String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +113

[ViewStateException: Invalid viewstate.
Client IP: 127.0.0.1
Port:
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0;
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322;
..NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR
3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729;
OfficeLiveConnector.1.4; OfficeLivePatch.1.3; msn OptimizedIE8;ENUS)
ViewState:
/wEPDwUKMTY2MDY1NTE2Ng8WAh4IQmVlbkhlcmVnFgJmD2QWBAIBD2QWAgIBDxYCHgRocmVmBRVTdHlsZVNoZWV0cy9CbGFjay5jc3NkAgMPZBYCAgEPZBYOAgMPEA8WAh4HQ2hlY2tlZGdkZGRkAgUPEA8WAh8CaGRkZGQCBw8QDxYCHwJoZGRkZAIJDxAPFgIfAmhkZGRkAgsPEA8WAh8CaGRkZGQCEQ88KwANAgAPFgIeC18hRGF0YUJvdW5kZ2QMFCsAAgUDMDowFCsAAhYQHgRUZXh0BQRIb21lHgVWYWx1ZQUESG9tZR4LTmF2aWdhdGVVcmwFHy9TdC4gTG91aXMgR29uemFnYS9EZWZhdWx0LmFzcHgeB1Rvb2xUaXAFFkdvIHRvIHRoZSBUaGVIb21lIFBhZ2UeB0VuYWJsZWRnHgpTZWxlY3RhYmxlZx4IRGF0YVBhdGgFHy9zdC4gbG91aXMgZ29uemFnYS9kZWZhdWx0LmFzcHgeCURhdGFCb3VuZGcUKwAOBTYwOjAsMDoxLDA6MiwwOjMsMDo0LDA6NSwwOjYsMDo3LDA6OCwwOjksMDoxMCwwOjExLDA6MTIUKwACFhAfBAUFQWRt...]

[HttpException (0x80004005): The state information is invalid for this page
and might be corrupted.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String
persistedState, String errorPageMessage, Boolean macValidationError) +106
System.Web.UI.ViewStateException.ThrowViewStateError(Exception inner,
String persistedState) +14
System.Web.UI.HiddenFieldPageStatePersister.Load() +217
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +105
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,
Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.admin_screenscraping_aspx.ProcessRequest(HttpContext context) +37
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +75
 
L

Leon

Leon said:
AAaron123 wrote:
Have any idea what might cause this error?
[SNIP]
I don't know what you are trying to do in ButtonDisplay_Click, but
altering the WebRequests and Responses from code isn't really "best
practise" and can be rather tricky.
I'd say, try to rewrite the function (or comment it) and try to run it
again

.L.

It's definetly due to that code.
All I'm doing is getting a copy of the html that my site sends, and
displaying it.

thanks


Here is the entire error.
I noticed the version at the end shows as 2.0 rather than 3.5
Who's framework is it refering to, me or the server?
Probably no one knows how to solve this because there are over 6000 google
hits with no answer that I could find.
I just wish I knew what the error means!
I.e., what data is in the "State Information"
[SNIP]

IIS is running in ASP 2.0, so that could be the case althought you're
extremely lucky if you are ^^ (wont bet on it)

The State information is the Viewstate. You'll get the same error when
your session is long dead and gone and you resend the page or when you
alter the viewstate before posting it back to the server.

If I'm right you want to get the HTML posted to the client on that
button_click, right? Why would you want that?
(just to make sure I'm getting it...)

..L.
 
A

AAaron123

Leon said:
Leon said:
On Tue, 21 Jul 2009 18:53:30 -0400, "AAaron123"

AAaron123 wrote:
Have any idea what might cause this error?
[SNIP]



I don't know what you are trying to do in ButtonDisplay_Click, but
altering the WebRequests and Responses from code isn't really "best
practise" and can be rather tricky.
I'd say, try to rewrite the function (or comment it) and try to run
it again

.L.

It's definetly due to that code.
All I'm doing is getting a copy of the html that my site sends, and
displaying it.

thanks


Here is the entire error.
I noticed the version at the end shows as 2.0 rather than 3.5
Who's framework is it refering to, me or the server?
Probably no one knows how to solve this because there are over 6000
google hits with no answer that I could find.
I just wish I knew what the error means!
I.e., what data is in the "State Information"
[SNIP]

IIS is running in ASP 2.0, so that could be the case althought you're
extremely lucky if you are ^^ (wont bet on it)

Why do you say that? Is ASP.NET2.0 unusual on a host IIS?

What does this mean: (wont bet on it)?
Isn't it obvious that my host's IIS is running in ASP 2.0?

The State information is the Viewstate. You'll get the same error when
your session is long dead and gone and you resend the page or when you
alter the viewstate before posting it back to the server.

It's not the delay that is the problem here.
If I'm right you want to get the HTML posted to the client on that
button_click, right? Why would you want that?
(just to make sure I'm getting it...)
I'm learning and just wanted to try.
I know the browsers let you look at the source code but I wanted to see if I
can get it.

Now I want to know what the problem is!

It always works the first time I retrieve the HTML and always fails the
second time I retrieve.

Is it comparing the Viewstate of my retrieving post to the viewstate if my
second post of the page?

Thanks
 
Ad

Advertisements

L

Leon

Leon said:
Leon wrote:
On Tue, 21 Jul 2009 18:53:30 -0400, "AAaron123"

AAaron123 wrote:
Have any idea what might cause this error?
[SNIP]



I don't know what you are trying to do in ButtonDisplay_Click, but
altering the WebRequests and Responses from code isn't really "best
practise" and can be rather tricky.
I'd say, try to rewrite the function (or comment it) and try to run
it again

.L.

It's definetly due to that code.
All I'm doing is getting a copy of the html that my site sends, and
displaying it.

thanks


Here is the entire error.
I noticed the version at the end shows as 2.0 rather than 3.5
Who's framework is it refering to, me or the server?
Probably no one knows how to solve this because there are over 6000
google hits with no answer that I could find.
I just wish I knew what the error means!
I.e., what data is in the "State Information"
[SNIP]

IIS is running in ASP 2.0, so that could be the case althought you're
extremely lucky if you are ^^ (wont bet on it)

Why do you say that? Is ASP.NET2.0 unusual on a host IIS?

What does this mean: (wont bet on it)?
Isn't it obvious that my host's IIS is running in ASP 2.0?

Yes it is obvious that it's running 2.0, but if you want it to run in
3.5 as a soltution > that's the thing I wont bet on..
It's not the delay that is the problem here.

I'm learning and just wanted to try.
I know the browsers let you look at the source code but I wanted to see if I
can get it.

Now I want to know what the problem is!

Looking at the beginning post - what do you do with the

Dim objRequest As WebRequest =
System.Net.HttpWebRequest.Create(TextBox1.Text) ?

You create (by code) a new item?

It always works the first time I retrieve the HTML and always fails the
second time I retrieve.

Is it comparing the Viewstate of my retrieving post to the viewstate if my
second post of the page?

Thanks

..L.
 
J

Juan T. Llibre

Check out this complete, working, example :

http://authors.aspalliance.com/stevesmith/articles/netscrape.asp

If you're using international characters, and not just ASCII ones, modify :

Dim sr As New StreamReader(objResponse.GetResponseStream())

to read :

Dim sr As New StreamReader(objResponse.GetResponseStream(), System.Text.Encoding.UTF7)






Juan T. Llibre, asp.net MVP
¿ Estas probando VS 2010 y ASP.NET 4.0 ?
Regístrate (gratis) en los Foros de VS 2010 y ASP.NET 4.0, en español
http://asp.net.do/foros/forums/
=====================================================
 
A

AAaron123

Leon said:
Leon said:
On Wed, 22 Jul 2009 07:50:38 -0400, "AAaron123"

Leon wrote:
On Tue, 21 Jul 2009 18:53:30 -0400, "AAaron123"

AAaron123 wrote:
Have any idea what might cause this error?

[SNIP]



I don't know what you are trying to do in ButtonDisplay_Click, but
altering the WebRequests and Responses from code isn't really
"best practise" and can be rather tricky.
I'd say, try to rewrite the function (or comment it) and try to
run it again

.L.

It's definetly due to that code.
All I'm doing is getting a copy of the html that my site sends, and
displaying it.

thanks


Here is the entire error.
I noticed the version at the end shows as 2.0 rather than 3.5
Who's framework is it refering to, me or the server?
Probably no one knows how to solve this because there are over 6000
google hits with no answer that I could find.
I just wish I knew what the error means!
I.e., what data is in the "State Information"

[SNIP]
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework
Version:2.0.50727.3082; ASP.NET Version:2.0.50727.4028

IIS is running in ASP 2.0, so that could be the case althought
you're extremely lucky if you are ^^ (wont bet on it)

Why do you say that? Is ASP.NET2.0 unusual on a host IIS?

What does this mean: (wont bet on it)?
Isn't it obvious that my host's IIS is running in ASP 2.0?

Yes it is obvious that it's running 2.0, but if you want it to run in
3.5 as a soltution > that's the thing I wont bet on..

ASP.NET2.0 can run with Framework v2??

Looking at the beginning post - what do you do with the

Dim objRequest As WebRequest =
System.Net.HttpWebRequest.Create(TextBox1.Text) ?

You create (by code) a new item?

create a WebRequest object (giving the URL)
I have to check to see if it should be a HTTPWebRequest object
 
Ad

Advertisements

A

AAaron123

I had to put the code he had in page_load, into a button event handler so I
could call it twice.
Got the same error the second time.

I used his vb script but in his C# script below:
-Shouldn't he be closing objResponse?
-Doesn't "using" close sr (i.e., he does need to) ?

void Page_Load(Object Src, EventArgs E) {
myPage.Text = readHtmlPage(http://aspadvice.com/blogs/ssmith/);
}
private String readHtmlPage(string url)
{
String result;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top