asp.net使用post方式action到另一个页面,在另一个页面接受form表单的值!(报错,已解决!)...
我想用post的方式把一個(gè)頁面表單的值,傳到另一個(gè)頁面。當(dāng)我點(diǎn)擊Default.aspx的Send提交按鈕時(shí),這個(gè)時(shí)候會(huì)action到Default2.aspx頁面,在這個(gè)時(shí)候就報(bào)錯(cuò)了,報(bào)的錯(cuò)誤是: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(不理解為什么是這樣!)
解決辦法:在要接受的頁面Default2.aspx加上<%@ Page Language="C#"? enableViewStateMac="false" %> 這個(gè),就可以了!
Default.aspx頁面的代碼:
<form id="form1" method="post" action="Default2.aspx" runat="server"><div>你的名字<asp:TextBox ID="name" runat="server"></asp:TextBox><br /><br /><input type="submit" value="Send" /><br /><br />學(xué)習(xí)request 和 response的用法<br /><br /><br /></div></form>
Default2.aspx頁面代碼:
string name = Request["name"];
Response.Write(name + "<br>");
Response.Write("你使用的是" + Request.RequestType + "方式傳送數(shù)據(jù)"); 只是在page_load里面加了接受form表單值的代碼! posted on 2014-03-20 15:32 NET未來之路 閱讀(...) 評(píng)論(...) 編輯 收藏
轉(zhuǎn)載于:https://www.cnblogs.com/lonelyxmas/p/3613854.html
總結(jié)
以上是生活随笔為你收集整理的asp.net使用post方式action到另一个页面,在另一个页面接受form表单的值!(报错,已解决!)...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: windows进程管理小工具procex
- 下一篇: asp.net ajax控件工具集 Au