[WebMethod(EnableSession = true)]
public static string SayHello()
{
LxUserContext depno = HttpContext.Current.Session["UserContext"] as LxUserContext;
string depnos = depno.User.Department.ID;
.......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using CityMgr;
using CityMgr.Base; namespace WebApp
{
/// <summary>
/// 用户上下文
/// </summary>
[Serializable]
public class LxUserContext
{
/// <summary>
/// 当前用户
/// </summary>
public LxPerson User { get; set; }
/// <summary>
/// 当前用户拥有的权限列表
/// </summary>
public List<LxAuth> HoldAuth { get; set; }
/// <summary>
/// 登录时间
/// </summary>
public DateTime LoginTime { get; set; }
/// <summary>
/// 客户端IP地址
/// </summary>
public string IP { get; set; } /// <summary>
/// 验证权限
/// </summary>
/// <param name="authId">权限ID</param>
/// <returns>是否拥有此权限</returns>
public bool ValidateAuth(string authId)
{
return HoldAuth.Contains(new LxAuth() { ID = authId });
} /// <summary>
/// 验证权限
/// </summary>
/// <param name="authIds">权限ID列表</param>
/// <returns>是否拥有此权限</returns>
public bool ValidateAuth(string[] authIds)
{
bool result = false;
foreach (var auth in authIds)
{
if (HoldAuth.Contains(new LxAuth() { ID = auth }))
result = true;
break;
}
return result;
} /// <summary>
/// 获取当前用户登录上下文
/// </summary>
/// <returns>用户登录上下文</returns>
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
public static LxUserContext GetCurUserContext()
{
var obj = HttpContext.Current.Session["UserContext"] as LxUserContext;
obj.User.Department.LoadData();
return obj;
} }
}

WebMethod Session的更多相关文章

  1. 如何解决设置Session保存在StateServer后引起WebService/WebMethod无法异步获取Session

    项目中有一个文件上传功能,需要显示文件上传进度.于是使用PageMethods 调用WebService/WebMethod . 在demo中测试一切正常.但是转移到项目中之后无法异步刷新文件上传进度 ...

  2. System.Web.HttpContext.Current.Session为NULL解决方法

    http://www.cnblogs.com/tianguook/archive/2010/09/27/1836988.html 自定义 HTTP 处理程序,从IHttpHandler继承,在写Sys ...

  3. 请求WebMethod, Ajax 处理更加专注

    在WebForm下 开发ajax程序,需要借助于一般处理程序(*.ashx)或web服务(*.asmx),并且每一个ajax请求,都要建一个这样的文件,如此一来,如 果在一个项目中ajax程序多了,势 ...

  4. ajax调用aspx.cs中的WebMethod

    前台: <script language="javascript" src="../js/jquery-1.8.2.js"></script& ...

  5. 用jQuery.ajaxWebService请求WebMethod,Ajax处理实现局部刷新

    首先在aspx.cs文件里建一个公开的静态方法,然后加上WebMethod属性. 如: [WebMethod]  public static string GetUserName()   {  //. ...

  6. WebMethod属性详解

    WebMethod有6个属性:.Description.EnableSession.MessageName.TransactionOption.CacheDuration.BufferResponse ...

  7. WebServices中使用Session

    默认情况下,Asp.net使用cookie来管理会话状态.因此,Asp.net假设客户端存储了会话cookie并将它与每一个请求一并发回给客户端. /// <summary> /// Su ...

  8. WebMethod 属性

    WebMethod有以下几种属性: BufferResponse CacheDuration Description EnableSession MessageName TransactionOpti ...

  9. System.Web.HttpContext.Current.Session为NULL值的问题?

    自定义 HTTP 处理程序,从IHttpHandler继承,在写System.Web.HttpContext.Current.Session["Value"]的时 候,没有问题,但 ...

随机推荐

  1. Kubernetes连接外部数据源

    Kubernetes架构下比较核心的问题是数据如何persistance,虽然提供了Persistent volumn的方式,但是对于像数据库之类的产品在kubernetes集群环境中运行和管理还是很 ...

  2. Restful Web Service部署到weblogic 12c

    介绍一下环境: 首先需要下载一个jaxrs-ri-2.22.2.zip的包 采用Jdeveloper 12c版本,jdk1.8 WebLogic Server 12.2.1版本 Restful项目建立 ...

  3. ylbtech-memorandum(备忘录)-数据库设计

    ylbtech-DatabaseDesgin:ylbtech-memorandum(备忘录)-数据库设计 -- ============================================ ...

  4. profiler

    推荐C++ 的profiler 用于GPU CPU 综合测试 FramePro http://www.puredevsoftware.com/ 可以在进度条上拉时间 查看GPU CPU bound

  5. Coincidence (动态规划求最长公共子序列)(王道)

    题目描述: Find a longest common subsequence of two strings. 输入: First and second line of each input case ...

  6. union中的成员不能有构造函数

    最近在做项目的CTA测试,快被折腾死了..... -_- 项目中用到的开源库AllJoyn在编译时报错: In file included :, , , , , , , : ./Target/:: e ...

  7. git学习——分支

    分支 创建分支:git branch 如:git branch testing Git通过HEAD指针知道用户是在哪一个分支上工作. 切换分支用git checkout命令,注意:可以用git sta ...

  8. ActiveMQ实现负载均衡+高可用部署方案 -转载

    转:http://www.open-open.com/lib/view/open1400126457817.html 一.架构和技术介绍 1.简介 ActiveMQ 是Apache出品,最流行的,能力 ...

  9. 在FASTBuild中使用Distribution

    上一篇:在FASTBuild中使用Caching 在FASTBuild中使用分布式(distribution)编译需要注意以下四个环节. 一.编译器设置 某些编译过程与分布式相矛盾,如果一个对象不能被 ...

  10. vue - rimraf

    rimraf 包的作用:以包的形式包装rm -rf命令,用来删除文件和文件夹的,不管文件夹是否为空,都可删除 const rimraf = require('rimraf'); rimraf('./t ...