登录控制问题

时间:2013-05-23 17:35:41

标签: asp.net login

我是软件工程和Web开发课程的初级学员,遇到了一个问题。我需要一个登录页面,以便在用户单击登录按钮后,它们将被发送到我的实际网页。但是,每次单击登录按钮时,我都会收到此错误:

Server Error in '/Case04' 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.

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.Web.HttpException: 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."

对于这个特定的项目,我不关心用户输入的内容,只要他们输入信息。我只是需要它,所以当点击登录按钮时,我被发送到我的实际网页,即pc.aspx。

这是我的代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<link href="login.css" rel="stylesheet" type="text/css" />
    <title></title>
</head>
<body>
<%--Heading--%>
<form name="c_order" id="c_order" runat="server" 
action="pc.aspx" method="get">
<table>
    <tr>
        <td>
            <img src="mclogog.jpg" alt="heading" id="heading" />
        </td>
    </tr>
</table>

<%--login--%>
<asp:Login ID="login" class="login" runat="server" size="10" maxlength="25" EventValidation="false"></asp:Login>
<p id="member" >Already a member?</p>

<%--fieldset for new user --%>
<fieldset>
 <legend id="bill">Shipping Information</legend>
       <label for="fname" >First Name<span>*</span></label>
       <input type="text" name="fname" id="fname" size="27" />
       <label for="lname"> Last Name<span>*</span></label> 
       <input type="text" name="lname" id="lname" size="27" />
       <label for="address1">Address #1<span>*</span></label>
       <input type="text" name="address1" id="address1" size="57" />
       <label for="address2">Address #2</label>
       <input type="text" name="address2" id="address2" size="57" />
       <label for="city">City<span>*</span></label></td>
       <input type="text" name="city" id="city" size="40" />
       <label for="state">State<span>*</span> </label>
       <input type="text" name="state" id="state" size="3" />
       <label for="zip">ZIP<span>*</span> </label>
       <input type="text" name="zip" id="zip" size="10" maxlength="10" />
       <label for="country">Country<span>*</span></label>
       <input type="text" name="country" id="country" size="40" value="United States" />
      <p id="ast">
        * = Required field, must be filled in. 
      </p>     
</fieldset>
</form>
</body>
</html>

感谢任何帮助,谢谢!

1 个答案:

答案 0 :(得分:0)

问题是您的页面没有处理自己的事件。你有你的&lt;形式&gt;标记设置为将其值回发到另一个页面。

&LT; form ... action =“pc.aspx” ... /&gt;但您的页面实际上称为 login.aspx 。因此,当此表单的内容发布到pc.aspx时,它无法解码viewstate,因为它不是来自pc.aspx.cs.它来自不同的页面。

从表单标记中删除action属性。像这样:

<form name="c_order" id="c_order" runat="server" method="get">