0

我添加了一个新的 asp.net 项目,它只在我的 MVC 应用程序之上托管(经典)WebServices。

Web 服务调用位于 Biz Layer Dll 中的 Biz Objects。

WebService 客户端就像普通用户一样,它们必须经过身份验证和每次操作的授权。

我在第一次调用时使用 SOAP 身份验证令牌来验证用户,然后在每次后续调用时传递该令牌。

BizObjects 访问 IUserSessionManager 以获取授权用户,然后根据请求调用授权用户。这对于 MVC 应用程序和调用 BusinessObjects 的 Windows 应用程序来说非常容易。那么如何将用户信息存储在我的 BusinessObjects 可以从中检索它们的以下系统中。(这对您来说可能很容易,但我不喜欢使用 Web 服务)

public class XyzUserSessionManager
{
    private static IXyzUserSessionManager _instance;
    public static IXyzUserSessionManager UserSessionManager
    {
        get { return _instance; }
        set { _instance = value; }
    }
    public static IXyzUserSession Current
    {
        get { return UserSessionManager.Current; }
    }
}


    public IXyzUserSession Current
    {
        get
        {
            if (HttpContext.Current == null || HttpContext.Current.Session == null || HttpContext.Current.Session[SessionKey] == null)
                return null;
            return (IXyzUserSession)HttpContext.Current.Session[SessionKey];
        }
        protected set
        {
            HttpContext.Current.Session[SessionKey] = value;
        }
    }
4

1 回答 1

0

您可以像常规 Web 应用程序一样启用会话状态支持。这是在每个方法的基础上完成的。在此处查看更多详细信息:http: //msdn.microsoft.com/en-us/library/aa480509.aspx

于 2012-11-09T08:23:11.017 回答