IHttpModule Init 未触发
我遇到了 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).
但是当我在服务中运行我的 webservice 时却没有,并且我收到错误,
ContextInfo.Current.User.LoginName;
因为 Current 为空。
我通过远程调试器检查这一点。
我有 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";
}
有什么想法吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应用程序池出现问题。
there was a problem with application pool.