0

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

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>

我会很感激任何帮助,谢谢!

4

1 回答 1

0

问题是您的页面没有处理自己的事件。您已将 <form> 标记设置为将其值回发到另一个页面。

< form ... action="pc.aspx" ... /> 但您的页面实际上称为login.aspx。因此,当这个表单的内容发布到 pc.aspx 时,它无法解码视图状态,因为它不是来自 pc.aspx.cs。它来自不同的页面。

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

<form name="c_order" id="c_order" runat="server" method="get">
于 2013-05-23T19:25:24.230 回答