Greeting everyone,
I have recently started working with asp.net , and deceided to jump to asp.net mvc. I am familiar with MVC and I used it to make application alot more robust.
I took time to get familiarise with MVC , and decided to make changes to the system to fit my needs. I donot prefer to have an extra click to login, so i decided to have loginform in LogOnUserControl.ascx . Please note that all the code I am using so far is provided by MVC application itself. I have just make teeny tiny adjustment. Following is my LogOnUserControl.ascx
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%
if (Request.IsAuthenticated)
{
%>
Welcome <b>
<%= Html.Encode(Page.User.Identity.Name) %></b>! [
<%= Html.ActionLink("Log Off", "LogOff", "Account") %>
]
<%
}
else
{
%>
<%= Html.ValidationSummary("Login was unsuccessful. Please correct the errors and try again.") %>
<% using (Html.BeginForm("LogOn", "Account"))
{ %>
<div id="loginForm">
<fieldset>
<legend>Login</legend>
<p>
<label for="username">
Username:</label>
<%= Html.TextBox("username")%>
<%= Html.ValidationMessage("username")%>
</p>
<p>
<label for="password">
Password:</label>
<%= Html.Password("password")%>
<%= Html.ValidationMessage("password")%>
</p>
<p>
<%= Html.CheckBox("rememberMe")%>
<label class="inline" for="rememberMe">
Remember me?</label>
</p>
<p>
<input type="submit" value="Log On" />
</p>
</fieldset>
</div>
<%
}
%>
<div id="registerHere">
<fieldset>
<legend>Register</legend>
<p>
Please enter your username and password.
<%= Html.ActionLink("Register","Register","Account") %>
if you don't have an account.
</p>
</fieldset>
</div>
<%
}
%>
Now the problem is that is the I can't login from this form. I get following error:
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.
I am not sure why I am getting error regarding it. I tried googling but solution provided didn't help much. Solution including removing form tags from site.master.
Your help is alot appreciated.
Thanks
With Regards
-Umang
![]()
![]()
![]()