无法通过Windows身份验证获取用户:“指定的登录会话不存在.它可能已经被终止. [英] Cannot get a user via Windows Authentication: "A specified logon session does not exist. It may already have been terminated."

查看:182
本文介绍了无法通过Windows身份验证获取用户:“指定的登录会话不存在.它可能已经被终止.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码在C#中获取用户名.它在我的计算机上可以正常运行,但是一旦将其部署到服务器上,它就会因错误消息而中断:指定的登录会话不存在.它可能已经终止."

I use the following code to get a users name in C#. It works perfectly fine on my computer, but as soon as I deploy it to a server it breaks with the error message: "A specified logon session does not exist. It may already have been terminated."

private bool isUserAuthenticated()
{
    return System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
}

private string getUserName()
{
    return System.Web.HttpContext.Current.User.Identity.Name;
}

我的web.config文件(摘录):

My web.config file (excerpt):

<system.web>
     <authentication mode="Windows" />
</system.web>

然后我继续在IIS上为网站启用Windows身份验证.

I then proceeded and enabled Windows Authentication for the website on IIS.

我错过了什么吗?这里可能是什么错误,我该如何解决?任何想法都受到高度赞赏.如果您需要更多信息,请发表评论.

Did I miss something? What could be the error here and how can I fix it? Any thoughts are highly appreciated. If you need more information please leave a comment.

推荐答案

当系统提示您输入Windows凭据时,您应该使用:

When you are prompted to enter the Windows credentials you should use:

服务器名\用户名密码

代替:

用户名密码

这篇关于无法通过Windows身份验证获取用户:“指定的登录会话不存在.它可能已经被终止.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆