开发者

IHttpModule Init not fired

开发者 https://www.devze.com 2023-01-04 00:50 出处:网络
I have got problem with contextInfo [WebMethod] [SoapHeader(\"UserInfo\", Direction = SoapHeaderDirection.In)]

I have got problem with 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; }
        }

When I run my asmx at local everything goes fine, it enter to

public void Init(HttpApplication httpApp).

But when I run my webservice at service it doesn't and I get error at

ContextInfo.Current.User.LoginName;

because Current is null.

I check this by remote debugger.

I have Windows Server 2008 and I am in domain like my server.

public class AuthenticateRequestHttpModule : IHttpModule
    {

        private HttpApplication mHttpApp;

        public void 开发者_Python百科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";
}

Any ideas ?


there was a problem with application pool.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号