C# 为什么这会导致错误?
这段代码在提交时总是返回一个错误,你知道为什么吗C# 为什么这会导致错误?,c#,javascript,jquery,ajax,iis,C#,Javascript,Jquery,Ajax,Iis,这段代码在提交时总是返回一个错误,你知道为什么吗 <script type="text/javascript"> $(function () { $('#Form1').submit(function (event) { var form = $(this); $.ajax({ type: form.attr('method'), url: form
<script type="text/javascript">
$(function () {
$('#Form1').submit(function (event) {
var form = $(this);
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize()
}).done(function () {
// Optionally alert the user of success here...
alert("Success");
}).fail(function () {
// Optionally alert the user of an error here...
alert("Error" + form.serialize());
});
event.preventDefault(); // Prevent the form from submitting via the browser.
});
});
$(函数(){
$('#Form1')。提交(函数(事件){
变量形式=$(此);
$.ajax({
类型:form.attr('method'),
url:form.attr('action'),
数据:form.serialize()
}).done(函数(){
//(可选)在此处提醒用户成功。。。
警惕(“成功”);
}).fail(函数(){
//(可选)在此处警告用户错误。。。
警报(“错误”+form.serialize());
});
event.preventDefault();//防止表单通过浏览器提交。
});
});
&时代;
报告问题
你有什么问题吗
投影仪
电视
视频会议
损坏
另外
关
发现发生此错误:
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.
“/”应用程序中出现服务器错误。
--------------------------------------------------------------------------------
viewstate MAC验证失败。如果此应用程序由Web场或群集托管,请确保配置指定了相同的validationKey和验证算法。无法在群集中使用自动生成。
它托管在运行IIS7的Windows服务器上,有什么想法吗?每次失败时它都会触发fail函数(函数(){//可以选择在此处向用户发出错误警报…警报(“错误”+form.serialize();});这仅仅意味着您的ajax请求失败。:)通过firebug运行它?服务器端的脚本可能会返回带有错误状态代码的标题。检查服务器返回的数据我猜不包括jquery。编辑-哦,好的,现在查看您的错误消息。
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.