webmethod启用会话 [英] webmethod enable session

查看:65
本文介绍了webmethod启用会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[WebMethod(EnableSession = true)]
        public static string AddBookmark(string inputText)
        {
            string[] ip = inputText.Split('~');
            if (ip[1] == "XXX")
            {
                return string.Format("Error");
            }
            else
            {
                /* enter data into db */
                Url_BLL obj = new Url_BLL();
                int i = obj.Add_Update_Url_BLL(ip[1].ToString(), ip[1].ToString(), ip[1].ToString(), ip[1].ToString(), ip[1].ToString(), Session["UserEmail"].ToString());
                /* enter data into db end */
                if(i==-1)
                    return string.Format("{0}", "Added!");
                else
                    return string.Format("{0}", "Sorry Error!");
            }
        }



运行这些代码时出错 -


While runing these code getting an error -

Error	36	An object reference is required for the non-static field, method, or property 'System.Web.UI.Page.Session.get'

无法得到它。请帮助。

推荐答案

此处已解决同样的问题:

http://stackoverflow.com/questions/7793752/get-session-variable-inside-a-method [ ^ ]
Same issue has been addressed here :
http://stackoverflow.com/questions/7793752/get-session-variable-inside-a-method[^]


这篇关于webmethod启用会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆