form表单提交

1.form表单提交.html页面失败

    <%--客户端form--%>
    <form id="form2" action="LoginOne.html" method="post">
        <div>
            用户名:  
            <input type="text" name="username" value="admin" />
            <input type="submit" />
        </div>
    </form>

说明:

  1. form表单以get方式可以提交到静态页面,post方式不可以提交到静态页面
  2. form表单post方式可以提交到.aspx/.ashx等动态页面。

响应过程:

 

2.runat=server的服务器表单提交制定action提交报错

异常详细信息: System.Web.HttpException: 验证视图状态 MAC 失败。如果此应用程序由网络场或群集承载,请确保 <machineKey> 配置指定了相同的 validationKey 和验证算法。不能在群集中使用 AutoGenerate。

 

    <%--服务器form 1 提交外域内动态页面--%>
    <form id="form1" runat="server" action="http://localhost:12621/login.aspx" method="post">
        <div>
            用户名:  
            <input type="text" name="f_user" value="admin" />
            <input type="text" name="f_pass" value="123456" />
            <input type="submit" />
        </div>
    </form>

 

解决方案1:从page指令中指定 EnableViewStateMac="false"

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs"
     EnableViewStateMac="false" 
    Inherits="Web.Login" %>

 

解决方案2:从Webconfig中指定 EnableViewStateMac="false"

<configuration>
  <system.web>
    <pages enableViewStateMac="false"></pages>

    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
  </system.web>
</configuration>

 

 

posted @ 2014-05-05 09:16  天马3798  阅读(224)  评论(0编辑  收藏  举报