Length cannot be less than zero

J

John Mason

Hi,

I have developed an asp.net application that uses forms authentication.
I have a local install and a remotely hosted install of the application.
Intermittently the remote application falls over with an error (see
below for details).

This seems to happen on different pages after an asp forms button is
clicked, and brings down the whole application when it does happen. When
it happens you cannot browse to any page within the application (even
the front login page).

As a temporary fix, the hosting company restarts the application pool
and/or web service.

This seems to be happening approximately once or twice a day.

Here is a screen dump of the error.....

Any help as to the cause, would be greatly appreciated!

Server Error in '/vs24100_secure/coc_admin' Application.
------------------------------------------------------------------------
--------

Length cannot be less than zero. Parameter name: length
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.ArgumentOutOfRangeException: Length cannot be
less than zero. Parameter name: length

Source Error:

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:


[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
System.String.Substring(Int32 startIndex, Int32 length) +172
System.Web.UI.Util.GetScriptLocation(HttpContext context) +200

System.Web.UI.WebControls.BaseValidator.RegisterValidatorCommonScript()
+69
System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +44
System.Web.UI.Control.PreRenderRecursiveInternal() +62
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Page.ProcessRequestMain() +1489
 
J

John Mason

I think I may have fixed it myself. I made the following change to all
my pages with validation controls last week, and so far the application
hasn't fallen over. (It had been failing at least once a day).

I have changed all validation controls to include
'enableclientscript=false' which means that the page will postback to
the server to verify that validation is correct, rather than doing it
all client-side.

I noticed that the 'BaseValidator.OnPreRender' was listed in the stack
trace. I discovered that this method allows you to change the viewstate
before it is rendered on the page...this would probably have something
to do with client/server side validation?
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top