Validation of viewstate MAC failed - asp.net

uncaught exception: [Exception...
"'Sys.WebForms.PageRequestManagerServerErrorException:
Sys.WebForms.PageRequestManagerServerErrorException:
Validation of viewstate MAC failed. If
this application is hosted by a Web
Farm or cluster, ensure that
configuration specifies
the same validationKey and validation
algorithm. AutoGenerate cannot be used
in a cluster.' when calling method:
[nsIDOMEventListener::handleEvent]"
nsresult: "0x8057001c
(NS_ERROR_XPC_JS_THREW_JS_OBJECT)"
location: "JS frame ::
chrome://firebug/content/spy.js ::
callPageHandler :: line 744" data: no]
Thing is, I don't even have a machineKey tag. I commented it out and I still get this error.
This is my entire web.config file:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="UrlRewriter">
<section name="PlainRules" type="System.Configuration.NameValueSectionHandler"/>
<section name="RegExRules" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<UrlRewriter>
<PlainRules configSource="UrlRewriter.plain.config" />
<RegExRules configSource="UrlRewriter.regex.config" />
</UrlRewriter>
<connectionStrings configSource="db.config"/>
<system.net>
<mailSettings>
<smtp configSource="mail.config"/>
</mailSettings>
</system.net>
<system.web>
<!--<machineKey validationKey=""
decryptionKey="" validation="SHA1" />-->
<compilation debug="true" targetFramework="4.0" />
<globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" />
<trace enabled="false"/>
<!--<customErrors defaultRedirect="~/error" mode="RemoteOnly"/>-->
<httpRuntime maxRequestLength="4000" executionTimeout="1000"/>
<authentication mode="Forms">
<forms defaultUrl="~/" loginUrl="~/login" timeout="43200" protection="All" cookieless="UseCookies" />
</authentication>
<membership defaultProvider="AspNetSqlMembershipProvider" hashAlgorithmType="SHA1">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" applicationName="damnation" connectionStringName="membership"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Hashed"
maxInvalidPasswordAttempts="20" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="5"
/>
</providers>
</membership>
<roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="membership" applicationName="damnation"/>
</providers>
</roleManager>
<profile defaultProvider="AspNetSqlProfileProvider" enabled="true" inherits="Damnation.Website.Shared.Membership.SharedMembershipProfile">
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="membership" applicationName="damnation"/>
</providers>
</profile>
<httpModules>
<add name="UrlRewriter" type="Damnation.Website.Shared.UrlRewriting.UrlRewriterModule"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Damnation.Website.Shared.UrlRewriting.UrlRewriterModule"/>
</modules>
</system.webServer>
</configuration>
What could be the issue here?
I should also mention that I tried with and without the rewriter (small module I wrote myself), so that's not the issue either here...
Update: this issue is caught by firebug when I try to login with membership, which causes a postback in an updatepanel.

If you don't have a machineKey in your config, its using the one from machine.config.
Is this site setup on a web farm? If so you should generate a machineKey and put it in all the web.config file installations for your site.

Related

Error index page of website from webconfig

I have an error in my index page and my hosting support tell me that the "web config" file has a problem
http://schoolearn.ir/pay
this is my website
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I have no database and my pages are static but i need to implement my website using asp.net
As error says: This error can be caused by a virtual directory not being configured as an application in IIS, so in the IIS you should convert the pay directory to a application or move the files to the root of the host (instead of the pay directory) and try again.

How can I get my project to run on the IIS7 server?

My ASP.net web application works on my machine, but will not work properly on the test or production server. It redirects to the login page instead of allowing Anonymous Authentication. I know that my project properties in Visual Studio include Anonymous Authentication.
Here is my project properties window:
My web.config file looks like this:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<!-- Removed for privacy -->
</connectionStrings>
<appSettings>
<!-- Removed for privacy -->
</appSettings>
<location path="ResetPassword.aspx">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" requireSSL="false" />
</authentication>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="<!-- Removed for privacy -->" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" minRequiredNonalphanumericCharacters="0" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="8" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="<!-- Removed for privacy -->" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="<!-- Removed for privacy -->" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
I should also mention that this web.config file matches the web.config file that is currently being used in production. It should work, but I just don't understand if there are some additional settings or inherited properties in IIS that are messing things up on my test server.
*Update: I was able to get this site working on a different server without changing anything in the web.config. It must be something in the configuration of the server.

Getting security exception error after adding web services(.asmx) on hosting server

I have added web service in my application. Working fine in my local IIS. But when I host web service folder and .asmx file to hosting server getting security exception. I also tried by adding . Then I am getting "This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using from an inherited configuration file." Please any one can help me to solve this issue.
web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0" defaultLanguage="c#">
<assemblies>
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
<authentication mode="Forms">
<forms defaultUrl="login.aspx"/>
</authentication>
<authorization/>
<httpRuntime executionTimeout="10800" maxRequestLength="10485760" useFullyQualifiedRedirectUrl="false"/>
<customErrors mode="Off"/>
<machineKey validationKey="6628ECBFB40F6F852AB543C23C0B83C1679C5AAE35AD72FACF5B9F4FDB70AA1F648A1D5877CE1F9D69F08BAD919BFBAC0976D9119B8F32CFB80814E4E943F8EE" decryptionKey="42F45B378301126EB4CCBA16995304263754EF116E08A81003A936CC04B7537F" validation="SHA1" decryption="AES"/>
<pages enableEventValidation="false" viewStateEncryptionMode="Never" validateRequest="false"/>
<identity impersonate="false"/>
<trust level="Full" originUrl="http://myhostsite.net"/>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<profileService enabled="true" />
</webServices>
</scripting>
</system.web.extensions>
<connectionStrings>
<add name="irisdb" connectionString="Data Source=192.185.8.483;Initial Catalog=ice2014;User ID=ice2014; Password=iri!; Integrated Security=False" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="conStr" value="Data Source=192.185.8.483;Initial Catalog=ice2014;User ID=ice2014; Password=iri!; Integrated Security=False;Timeout=900" />
<add key="irisdb" value="Data Source=192.185.8.483;Initial Catalog=ice2014;User ID=ice2014; Password=iri!; Integrated Security=False;Timeout=500" />
</appSettings>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824"/>
</requestFiltering>
</security>
<staticContent/>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ICEServiceSoap"/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:3798/ICE%20Application/ICEService.asmx" binding="basicHttpBinding" bindingConfiguration="ICEServiceSoap" contract="Service.ICEServiceSoap" name="ICEServiceSoap"/>
</client>
</system.serviceModel>
</configuration>
Thank you in advance

web.config error

Hello everyone can someone help me with my web.config file? I am having error. I just want you guys to look at it and if there are errors someone that needs correction. Thank you all:
This is the error message:
Warning 1 The 'targetFramework' attribute is not declared. G:\display images in gridview\Web.config 17 62 Miscellaneous Files
Message 2 Could not find schema information for the element 'modules'. G:\display images in gridview\Web.config 51 7 Miscellaneous Files
Message 3 Could not find schema information for the attribute 'runAllManagedModulesForAllRequests'. G:\display images in gridview\Web.config 51 15 Miscellaneous Files
Error 4 The 'configuration' start tag on line 10 does not match the end tag of 'system.web'. Line 101, position 4. (C:\Users\Collins\Documents\Visual Studio 2005\WebSites\living to please god world\web.config line 101)
Here is the Web.config file:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/"/>
</providers>
</profile>
<authentication mode="Forms">
<forms loginUrl="login.aspx" defaultUrl="Default.aspx"/>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
<location path="PhotoAdmin">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<system.net>
<mailSettings>
<smtp from="some#example.com">
<network host="relay-hosting.example.net" password="" userName=""/>
</smtp>
</mailSettings>
</system.net>
</configuration>
Well there are several things that are messed up.
The targetFramework attribute must be specified if the application pool that you are using is set up to use .Net Framework 4. If this is the case then you should have the following section under system.web:
<compilation debug="true" targetFramework="4.0" />
The system.web section is closed too earlier. The sections 'pages', 'membership', 'profile', 'authentication' and 'authorization' must be subsections of system.web.

ASP.NET FormsAuthentication.Authenticate() is not working

I have created a user by using CreateUserWizard - control.
My web.config file is as follows:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="ConnString1" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=IceWebPortal_SQL2K5;user=sa;password=;integrated security=true;" providerName="System.Data.SqlClient"/>
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=aspnet_membership_test;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<!--
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" />
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms
name="CookieDemo"
loginUrl="Default.aspx"
protection="All"
timeout="30"
path="/"
/>
</authentication>
<!--<authorization>
<deny users="?"/>
</authorization>-->
</system.web>
<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*"></allow>
</authorization>
</system.web>
</location>
</configuration>
I am finding that, FormsAuthentication.Authenticate(username, password); is always returning false.
string username = this.usernameTextBox.Text;
string password = this.passwordTextBox.Text;
bool success = FormsAuthentication.Authenticate(username, password);
if (success)
{
}
What can be the problem?
You need to add e.g. a MembershipProvider configuration or add users directly to web.config (which is probably not a good idea)-
Example:
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
applicationName="/" />
</providers>
</membership>

Resources