2010-09-28 69 views
1
function getMainContent(ID, num, lang){ 
$.ajax({ 
    type: "POST", 
    url: "WebMethods.aspx/showMain", 
    data: '{AID: "' + articleID+ '", ANum: "' +num + '"}', 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 
    success: showSuccess, 
    failure: function(response) { 
     alert(response); 
    } 
}); 

lang在我的页面上以Session [“Lang”]形式提供。 如何访问并将其发送到Web方法?将asp.net会话变量传递给通过jquery调用的Web方法

回答

7

您可以直接访问会话页面方法中:

[WebMethod(EnableSession = true)] 
public static string ShowMain() 
{ 
    var lang = HttpContext.Current.Session["Lang"]; 
    return "foo"; 
} 
+0

感谢达林。这工作。 – Churchill 2010-09-28 10:23:51

+0

谢谢...你节省了我的时间 – 2014-01-21 09:41:40

相关问题