views:

55

answers:

1

Hi,

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 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 ?

A: 

there was a problem with application pool.