IHttpModule Init没有被解雇

时间:2010-06-21 15:02:37

标签: c# soap web-services httpmodule httpcontext

我遇到了contextInfo

的问题
[WebMethod]
[SoapHeader("UserInfo", Direction = SoapHeaderDirection.In)]
public void TestContext()
        {
            var user = ContextInfo.Current.User.LoginName;
        }

UserInfo _userInfo;
        [System.Xml.Serialization.SoapElement(IsNullable = true)]
        public UserInfo UserInfo
        {
            get { return _userInfo; }
            set { _userInfo = value; }
        }

当我在本地运行我的asmx时一切正常,它进入

public void Init(HttpApplication httpApp).

但是,当我在服务中运行我的web服务时,它没有,我在

得到错误
ContextInfo.Current.User.LoginName;

因为Current为null。

我通过远程调试器检查这个。

我有Windows Server 2008,我在域中就像我的服务器。

public class AuthenticateRequestHttpModule : IHttpModule
    {

        private HttpApplication mHttpApp;

        public void Init(HttpApplication httpApp)
        {
            this.mHttpApp = httpApp;

            mHttpApp.AuthenticateRequest += new EventHandler(OnAuthentication);
        }
...
}

ContextInfo:

public class ContextInfo
{

    public static void Create(User user)
    {
        HttpContext.Current.Items.Add(ITEM_KEY, new ContextInfo(user));
    }

          public static ContextInfo Current
    {
        get
        {
            return HttpContext.Current.Items[ITEM_KEY] as ContextInfo;
        }
    }


         private ContextInfo(User user)
    {

        _user = user;
    }

    public User User
    {
        get { return _user; }
    }


    User _user;
    private const string ITEM_KEY = "ContextInfo";
}

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

应用程序池出现问题。