Javascript 添加母版页后,为什么在AJAX调用期间HttpContext值丢失

Javascript 添加母版页后,为什么在AJAX调用期间HttpContext值丢失,javascript,jquery,asp.net,ajax,Javascript,Jquery,Asp.net,Ajax,我已经好几天没有试图解决这个问题了。 我有一个网页,是一个邮件收件箱在网站上。你可以像在facebook上一样从列表中向朋友发送消息 它在js文件、2个ashx文件和aspx、aspx.cs文件中包含AJAX代码 当用户想要向朋友发送消息时,我正在使用facebox弹出窗口。 现在,我更改了UI,删除了facebox,并添加了母版页,这样现在该页面与网站上的任何其他页面都一样。但是在向messages.aspx页面添加母版页之后 单击send message后,HttpContext的值变为nu

我已经好几天没有试图解决这个问题了。 我有一个网页,是一个邮件收件箱在网站上。你可以像在facebook上一样从列表中向朋友发送消息

它在js文件、2个ashx文件和aspx、aspx.cs文件中包含AJAX代码

当用户想要向朋友发送消息时,我正在使用facebox弹出窗口。 现在,我更改了UI,删除了facebox,并添加了母版页,这样现在该页面与网站上的任何其他页面都一样。但是在向messages.aspx页面添加母版页之后 单击send message后,HttpContext的值变为null。 当页面第一次加载显示好友列表和以前的消息时,它们工作正常。当我启动一个js函数来保存通过单击send输入的消息时,它就丢失了

在message.aspx页面中,我使用了3个隐藏字段:

<script>
    function SavePostedMessage() {
        var SenderAccountID = $("#hdnSenderID").val();
        var ReceiverAccountID = $("#hdnReceiverID").val();
        var Days = $("#hdnDays").val();
        var body = GetmessageData();
        if (body != null || body != "")
            SaveMessageInDatabase(SenderAccountID, ReceiverAccountID, body, Days);
    }
</script>
<asp:HiddenField ID="hdnSenderID" runat="server" />
<asp:HiddenField ID="hdnReceiverID" runat="server" />
<asp:HiddenField ID="hdnDays" runat="server" />

<a style="cursor: pointer;" onclick="SavePostedMessage()">

    <div style="height: 25px; width: 85px; float: left; margin-top: 28px; padding-top:     5px; background: #01B2E5; text-align: center;" id="uploadifyContainer">
        <span style="color: White; font-size: 12px;font-weight:bold; margin-left: 5px; border: 1px solid #D4D4D4;"  id="Content_lblAddPhoto">Send</span>
    </div>
</a>
</div>
在Ajax.js中,我定义了

function GetMessageConversation(SenderAccountID, ReceiverAccountID, Days) {
    $("#hdnSenderID").val(SenderAccountID);
    $("#hdnReceiverID").val(ReceiverAccountID);
    $("#hdnDays").val(Days);
    $("#divPostComment").show();
    setSelected("trUser" + ReceiverAccountID);
    $.ajax({
        type: "POST",
        url: "/MessageFacebox/GetMessageConversation.ashx",
        data: 'SenderAccountID=' + SenderAccountID + "&ReceiverAccountID=" + ReceiverAccountID + "&Days=" + Days,
        success: function (data) {
            $('#messageconversationdata').html(data);
            Scrollbottom();
        },
        error: function (errordata) {
            alert('Sorry some error occurred');
        }
    });
}

function SaveMessageInDatabase(SenderAccountID, ReceiverAccountID, Body, days) {

    $.ajax({
        type: "POST",
        url: "/MessageFacebox/SaveMessage.ashx",
        data: 'SenderID=' + SenderAccountID + "&ReceiverID=" + ReceiverAccountID + "&Body=" + Body,
        success: function (data) {
            GetMessageConversation(SenderAccountID, ReceiverAccountID, days);
        },
        error: function () {
            alert('Sorry some error occurred');
        }
    });
}
在GetMessageConversation.ashx中

context.Request.Form[“SenderAccountID”]
context.Request.Form[“ReceiverAccountID”]
返回存储的值

Account senderAccount = _accountRepository
    .GetAccountByAccountID(Convert.ToInt32(context.Request.Form["SenderAccountID"]));

Account receiverAccount = _accountRepository
    .GetAccountByAccountID(Convert.ToInt32(context.Request.Form["ReceiverAccountID"]));
但是在SaveMessage.ashx中

Account senderAccount = _accountRepository
    .GetAccountByAccountID(Convert.ToInt32(context.Request.Form["SenderID"]))   ;

Account receiverAccount = _accountRepository
    .GetAccountByAccountID(Convert.ToInt32(context.Request.Form["ReceiverID"]    ));
context.Request.Form[“SenderID”]
context.Request.Form[“ReceiverID”]
具有空值

第一个在第一次访问页面时加载。当用户输入消息并单击messages.aspx中的send按钮时,将调用save函数

没有母版页,一切都很好。一旦我将母版页文件添加到messages.aspx,代码就会停止工作

提前谢谢

Account senderAccount = _accountRepository
    .GetAccountByAccountID(Convert.ToInt32(context.Request.Form["SenderID"]))   ;

Account receiverAccount = _accountRepository
    .GetAccountByAccountID(Convert.ToInt32(context.Request.Form["ReceiverID"]    ));