zoukankan      html  css  js  c++  java
  • 此页的状态信息无效,可能已损坏应用程序中的服务器错误

    今天用JQUERY做了一个登录实验,在点击登录按钮后出现了标题的错误/

    网上得出的结论是:

    问题描述,页面A.aspx使用Ajax载入B.aspx进行分页.但在页面A中有服务器端控件,需要与服务器端交互,完成某些功能.

    但在单击服务器控件准备与服务器端进行交互时,出现错误信息:

    此页的状态信息无效,可能已损坏。 

    说明执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

    异常详细信息System.Web.HttpException: 此页的状态信息无效,可能已损坏。

    源错误: 

    [没有相关的源行]


    源文件c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\teacherwebsite\aba2332f\c906139a\App_Web_ppk8ycdo.10.cs    

    堆栈跟踪: 

    [FormatException: Base-64 字符串中的无效字符。]

    System.Convert.FromBase64String(String s) +0

    System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +67

    System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4

    System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37

    System.Web.UI.HiddenFieldPageStatePersister.Load() +136

     

    通过上网查询,给出以下解决方案:

    在该工程中的web.config中添加如下代码:

    <pages enableEventValidation="False" viewStateEncryptionMode="Never" />

    来源: http://www.cnblogs.com/ufo0303/archive/2008/04/10/1146026.html

    但是,按照网上给出的方法并没有解决问题.

    于是, 参见: http://blog.csdn.net/Yamzef/archive/2007/03/26/1541160.aspx .其中说:

    如果你在回调前不加这两句的话 __theFormPostData就会在原来的基础上再添加现有的网页状态post数据,这样可以说现在回调时你已包含了两份post数据,但回调时,服务器方仍然把它当作一份看待,结果服务器分析不出post数据,只给你返回了一个网页状态已损坏的消息 

    分析,可能是B页面,包含form表单才造成问题出现.于是删除B.aspx中的Form标签.问题解决.


    我的源码:

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

    <!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 runat="server">
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
    <title>无标题页</title>
    <script type="text/javascript">
    $(function(){
    var messagetext
    ="";
    $(
    "#tbxUser").focus(function(){
    if( $("#messageUser").text()=="可以注册!")
    {
    $(
    "#messageUser").html("可以注册!").show();
    }
    if($("#messageUser").text()=="") $("#messageUser").html("*用户名以字母或数字开头!").show();
    //else $("#messageUser").html("*用户名以字母或数字开头!").show();
    });
    $(
    "#tbxUser").blur(function(){
    var param
    =$("#tbxUser").val();
    $(
    "#messageUser").load("ajaxData.aspx?username="+param,function(responseText,textStatus,XMLHttpRequest){
    $(
    "#messageUser").html(responseText).show();
    messagetext
    =$("#messageUser").text();
    function(){location.href
    ="index.aspx"};
    alert(
    "aa");
    });
    });
    });
    </script>
    <style type="text/css">
    <!--
    *{ margin:0; padding:0;}
    .logion{ 400px; height:25px;}
    .beformessage{
    float:left;}
    .showmessage{
    float:left; margin-left:15px; display:none; font-size:12px; color:red;}
    #logionButton{ margin
    -left:64px;}
    #yanzhen{
    float:left;}
    -->
    </style>
    </head>
    <body>
    代码中Logion.asp页面中JQUERY的 $("#messageUser").load()方法的地址为ajaxData.aspx

    此时ajaxData.aspx页中有from,Logion.asp中也有FROM,所以在回调时包含了两份POST数据,删除ajaxData.aspx中的FROM表单错误解决了。

  • 相关阅读:
    设计模式的四个基本要素
    拖拉记录上下移动--Ajax UI
    Rails-Treasure chest2 嵌套表单;
    YAML(摘录)
    Rails-Treasure chest1 (自定义Model网址;多语言包; 时区设置, TimeZone类; 格式日期时间; 表单单选UI; 表单多选UI;Select2 Plugin)
    iTerm2的设置和Zsh.
    **优化--后端**: 计数缓存counter_cache; rack-mini-profiler(2300🌟) ; bullet(5000✨):侦测N+1query
    优化--前端(全占课,未完成作业:);CDN; Http/2的设置(未完成)
    null值的判断
    if else
  • 原文地址:https://www.cnblogs.com/sheseido/p/1874801.html
Copyright © 2011-2022 走看看