jQuery를 사용하여 PageMethod를 호출하여 몇 가지 Session 변수를 설정해야합니다. 이 같은PageMethod (asp.net)에서 세션 설정
클라이언트 측 JS 보이는이 같은
function setSession(Amount, Item_nr) {
//alert(Amount + " " + Item_nr);
var args = {
amount: Amount, item_nr: Item_nr
}
//alert(JSON.stringify(passingArguments));
$.ajax({
type: "POST",
url: "buycredit.aspx/SetSession",
data: JSON.stringify(args),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function() {
alert('Success.');
},
error: function() {
alert("Fail");
}
});
}
와 서버 측 :
[System.Web.Services.WebMethod(EnableSession = true)]
public static void SetSession(int amount, int item_nr)
{
HttpContext.Current.Session["amount"] = amount;
HttpContext.Current.Session["item_nr"] = item_nr;
}
아니라,이 세션 바르가 설정되어 있지 않은 것 같다. 세션 vars를 Response.Write하려고하면 아무것도 얻지 못합니다. 오류가 없으며 onclick 이벤트에서 js 함수로 전달 된 값을 경고 할 수 있으므로 해당 값이 있습니다.
내가 놓친 사람이 있습니까?
Thnx