Click here to Skip to main content
16,018,949 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
Dear All,
I am facing problem when i visit my site for posting data or just browing after some time of open and i also set session time out <sessionstate timeout="540">
but still facing problem website give runtime error.
and after that i have set custom error off
then new error raise

C#
Server Error in '/' Application.
--------------------------------------------------------------------------------

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

See http://go.microsoft.com/fwlink/?LinkID=314055 for more information. 


See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.

Source Error: 


[No relevant source lines] 

Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fd0b3228\1d95266\App_Web_j3v4lbmw.4.cs    Line: 0 

Stack Trace: 


[ViewStateException: Invalid viewstate. 
	Client IP: 103.206.131.163
	Port: 55571
	Referer: http://digitalgreedy.com/ADMIN/ProductData_Posting.aspx
	Path: /ADMIN/ProductData_Posting.aspx
	User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
	ViewState: /wEPDwUKLTkzNjg2NzU2MA9kFgJmD2QWAgIFDxYCHgdlbmN0eXBlBRNtdWx0aXBhcnQvZm9ybS1kYXRhFgICBw9kFgICAQ8PZBYCHglvbmtleWRvd24FkgJpZihldmVudC53aGljaCB8fCBldmVudC5rZXlDb2RlKXtpZiAoKGV2ZW50LndoaWNoID09IDEzKSB8fCAoZXZlbnQua2V5Q29kZSA9PSAxMykpIHtpZihkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnQ29udGVudFBsYWNlSG9sZGVyMV90eHRUcmFuSUQnKS52YWx1ZT09Jycpe3JldHVybiBmYWxzZTt9ZWxzZXtkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnQ29udGVudFBsYWNlSG9sZGVyMV9idG5WaWV3JykuY2xpY2soKTtyZXR1cm4gZmFsc2U7fX19IGVsc2Uge3JldHVybiB0cnVlfTsgZGTTYjB99ocAv1Cth+GNb52+pD3vkki5i7XYLqikLIlWRA==]

[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

See http://go.microsoft.com/fwlink/?LinkID=314055 for more information.]
   System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +116
   System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) +425
   System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Deserialize(String serializedState, Purpose purpose) +13
   System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) +40
   System.Web.UI.HiddenFieldPageStatePersister.Load() +247
   System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +251
   System.Web.UI.Page.LoadAllState() +41
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6605
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +279
   System.Web.UI.Page.ProcessRequest() +72
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +22
   System.Web.UI.Page.ProcessRequest(HttpContext context) +58
   ASP.admin_productdata_posting_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\fd0b3228\1d95266\App_Web_j3v4lbmw.4.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +188
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
 


--------------------------------------------------------------------------------



after that i am search for above error then google suggest set mechinekey into my webconfig file
when set machine key then my website response internal error 500

kindly suggest me for my problem
Thanks in Advance

What I have tried:

XML
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
	<configsections>
		<sectiongroup name="devExpress">
			<section name="compression" type="DevExpress.Web.ASPxClasses.CompressionConfigurationSection, DevExpress.Web.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirepermission="false" />
			<section name="themes" type="DevExpress.Web.ASPxClasses.ThemesConfigurationSection, DevExpress.Web.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirepermission="false" />
			<section name="errors" type="DevExpress.Web.ASPxClasses.ErrorsConfigurationSection, DevExpress.Web.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirepermission="false" />
		</sectiongroup>
	</configsections>
	<connectionstrings>
		<add name="GREEDY_ConnString" connectionstring="Data Source=103.23521536;Initial Catalog=12;User ID=12fhfg;Password=456456@12345;" providername="System.Data.SqlClient" />
	</connectionstrings>
	<system.net>
		<mailsettings>
			<smtp deliverymethod="Network">
        <network host="testn" port="215" username="abc" password="xyzi" />

      </smtp>
		</mailsettings>
	</system.net>
 <system.web>
		<identity impersonate="false" username="adminstrator" password="admin" />
		<authentication mode="Windows" />

    <customerrors mode="Off">
      <error statuscode="403" redirect="NoAccess.htm" />
      <error statuscode="404" redirect="FileNotFound.htm" />
    </customerrors>
    <authorization>
			<allow users="*" />
		</authorization>
  
   
   
		<pages controlrenderingcompatibilityversion="4.0" clientidmode="AutoID" enableviewstatemac="true">
			<controls>
				<add tagprefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
			</controls>
		</pages>
		<!--
          Set compilation debug="true" to insert debugging
          symbols into the compiled page. Because this
          affects performance, set this value to true only
          during development.
    -->
		<compilation debug="true" targetframework="4.0">
			<assemblies>

				<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
				<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
				<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
				<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
				<add assembly="System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
				<add assembly="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
			</assemblies>
		</compilation>
		<httphandlers>
			<!--<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />-->
			<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
		</httphandlers>
    
    
    <httpruntime executiontimeout="90" maxrequestlength="65536" usefullyqualifiedredirecturl="false" minfreethreads="8" minlocalrequestfreethreads="4" apprequestqueuelimit="100" enableversionheader="true" />
    <sessionstate timeout="540" />
    <!--<sessionstate mode="InProc" statenetworktimeout="60" sqlcommandtimeout="30" cookiename="ASP.NET_SessionId" timeout="120" regenerateexpiredsessionid="False" />-->
   
	</system.web>
	<system.webserver>
		<validation validateintegratedmodeconfiguration="false" />
		<handlers>
			<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" precondition="integratedMode" />
			<add name="ChartImageHandler" precondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
		</handlers>

    <directorybrowse enabled="false" />
    <defaultdocument>
      <files>
        <clear />
        <add value="index.aspx" />
        <add value="Default.htm" />
        <add value="Default.asp" />
        <add value="index.htm" />
        <add value="index.html" />
        <add value="iisstart.htm" />
        <add value="default.aspx" />
        <add value="index.php" />
      </files>
    </defaultdocument>
    </system.webserver>
	
	<location allowoverride="true" inheritinchildapplications="true">
		<appsettings>
			
			<add key="GREEDY_ConnString" value="Data Source=103.525.105152;Initial Catalog=fghfh;User ID=fghfgh;Password=fghffg@12345;Connect Timeout=200; pooling='true'; Max Pool Size=200" />

      <add key="CrystalImageCleaner-AutoStart" value="true" />
      <add key="biomatrictimesheet" value="true" />
      <add key="CrystalImageCleaner-Sleep" value="60000" />
      <add key="CrystalImageCleaner-Age" value="120000" />
      <add key="SmtpSSL" value="true" />
      <add key="Timeout" value="1000000" />
      <add key="Log4netConfigFile" value="logging.config" />
      <add key="ChartImageHandler" value="storage=memory;timeout=36000;deleteAfterServicing=false;privateImages=false;" />
      <add key="AttachmentPath" value="C:/PaySlip_Attachment" />
      <add key="aspnet:MaxHttpCollectionKeys" value="3000000" />
	
		</appsettings>
	</location>
	<runtime>
    
		<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentassembly>
				<assemblyidentity name="CrystalDecisions.Shared" publickeytoken="692fbea5521e1304" />
				<bindingredirect oldversion="10.2.3600.0" newversion="10.5.3700.0" />
			</dependentassembly>
			<dependentassembly>
				<assemblyidentity name="CrystalDecisions.Shared" publickeytoken="692fbea5521e1304" />
				<bindingredirect oldversion="10.2.3600.0" newversion="10.5.3700.0" />
			</dependentassembly>
		</assemblybinding>
	</runtime>
	<devexpress>
		<compression enablehtmlcompression="false" enablecallbackcompression="true" enableresourcecompression="true" enableresourcemerging="false" />
		<themes enablethemesassembly="true" />
		<errors callbackerrorredirecturl="" />
	</devexpress>
 </configuration>
Posted
Updated 9-Jun-16 18:01pm
v2
Comments
Richard Deeming 3-Jun-16 13:57pm    
Adding a <machineKey> is the correct solution. What was the full error you got when you tried to add one?
ArvindTomar 3-Jun-16 21:40pm    
When use machinekey then webpage not open show error(internal error 500)
Richard Deeming 6-Jun-16 10:22am    
Yes, you said that. But we need the FULL error to know what the problem is.

Try opening the site from a browser running on the server. IIS should give you a detailed error page with the full details of the error.

1 solution

Hi Arvind,

Just add this code on your web.config file

<pages enableeventvalidation="false" viewstateencryptionmode="Never" />


Above line should be included within section.

OR

if you dont want this solution to implemented on project level then you can add these attribute to the page(Top most line of HTML view) directive of the page which is creating issue.

That means you have to add enableEventValidation="false" viewStateEncryptionMode="Never" in page directive.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900