0

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;
}

My web.config file (excerpt):

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

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

Screenshot of my IIS authentication screen

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.

dislick
  • 667
  • 1
  • 7
  • 25
  • What are you using to connect from a client perspective? – Allan Elder Apr 16 '14 at 14:13
  • @AllanElder Internet Explorer. A small window pops up where I can enter my Windows credentials, if entered correctly it displays the said error message. – dislick Apr 16 '14 at 14:15

2 Answers2

0

try the below mentioned work around:

  1. On the Management Server, click Start, click Run, type gpedit.msc, and then click OK.
  2. Under Computer Configuration, expand Windows Settings, expand Security Settings, expand Local Policies, and then expand Security Options.
  3. In the Policy pane, right-click Network access: Do not allow storage of credentials or .NET Passports for network authentication, click Properties, click Disabled, and then click OK.
Brandon Boone
  • 16,281
  • 4
  • 73
  • 100
Delta
  • 149
  • 9
  • Checkout below link may be helpful http://bartwullems.blogspot.in/2012/08/iis-manager-error-specified-logon.html – Delta Apr 16 '14 at 14:33
0

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

servername\username password

instead of:

username password

chemark
  • 1,181
  • 1
  • 13
  • 19