student Box Office

Learn more from here.

student Box Office

We will prepare the best articles for you to acquire knowledge.

student Box Office

We will help you always. Just follow our guidelines.

student Box Office

Come and join here to share the knowledge in latest Technologies.

student Box Office

Share your views with us. And update your knowledge.

Showing posts with label ASP.Net C# Errors. Show all posts
Showing posts with label ASP.Net C# Errors. Show all posts

May 19, 2012

'Operation is not valid due to the current state of the object' error during postback


'Operation is not valid due to the current state of the object' error during postback



I had a aspx page which was working well, but suddenly I am getting the error "Operation is not valid due to the current state of the object." whenever a postback is done.
The stack trace is:
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()
at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)
at System.Web.HttpRequest.FillInFormCollection()

Solution:


<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="10000" />
</appSettings> 

Dec 18, 2011

AsyncFileUpload "Cannot Access A Closed File" exception

Add following code in web.config:

<system.web>

<httpRuntime executionTimeout="90" maxRequestLength="20000" useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="8192"/>

</system.web>

Nov 8, 2011

No http handler was found for request type 'GET'


This is what you need for ASP.NET 4.0 / IIS 7.5 on Windows 7:
Your web.config must contain the following:
<appSettings>
  <add key="ChartImageHandler" value="storage=file;timeout=20;" />
</appSettings>

<compilation targetFramework="4.0">
 <assemblies>
  <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
 </assemblies>
</compilation>
<system.webServer>
<handlers>
      <add name="ChartImg" verb="*" path="ChartImg.axd"  type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"  />
    </handlers>
</system.webServer>
You also need this at the top of your aspx page:
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>

Nov 1, 2011

Object cannot be cast from dbnull to other types

This is a common error that you get when trying to display a field with no value (null), from a table.
Sol:
Convert.IsDBNull(dt.Rows[i]["Pass1"]) ? null : dt.Rows[i]["Pass1"].ToString();

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More