0

I'm converting my current MVC application which uses windows based authentication to forms based. I have made changes in web.config and global.asax file. Now when I run the application, it goes to login page and with the user's credentials validated, its gets navigated to other page. My issue is when I do a signout, my applicationhost.config file gets rewrited from

 <windowsAuthentication enabled="false" />

to

<windowsAuthentication enabled="true" /> 

and then if I hit the home page of my application, it takes my windows credentials.

In my web config I do have

  <authentication mode="Forms">
      <forms loginUrl="~/Logon/Index"></forms>
    </authentication>
    <authorization>
      <deny users="?" />
    </authorization>

In global.asax I have

 string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
 string roles = string.Empty;
 //Let us set the Pricipal with our user specific details
 HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(
                          new System.Security.Principal.GenericIdentity(username, "Forms"), roles.Split(';'));
 ISecurityUserIdentity objUser = null;
 objUser = SecurityLibrary.Security.GetUser(username, Mgr.GetSecurityAttribute());
 Context.User = objUser;

My issue is why my applicationhost.config file rewrites automatically when I do a signout and change my authentication mode.

RBT
  • 24,161
  • 21
  • 159
  • 240
shakz
  • 629
  • 3
  • 14
  • 38
  • 2
    How about [this][1] method for IIS8 Express? [1]: https://stackoverflow.com/questions/4762538/iis-express-windows-authentication – EkzoMan Mar 27 '15 at 07:55
  • 1
    Yes I resolved my problem using the following steps. select the web project and press F4 to focus the Properties panel. Set the "Windows Authentication" property to disabled, and the "Anonymous Authentication" property to enabled. Thanks EkzoMan – shakz Mar 27 '15 at 13:13
  • Does this answer your question? [IIS Express Windows Authentication](https://stackoverflow.com/questions/4762538/iis-express-windows-authentication) – RBT Sep 16 '21 at 05:05

0 Answers0