How to handle "Enable default content page" setting in IIS?

May 24, 2010 at 7:55 PM

Authentication is not working when "Enable default content page" setting is enabled in IIS and default page is not specified as part of the URL.

EX: If default content page is set to "default.aspx" in IIS for a website XYZ.COM then the authentication is working fine for XYZ.COM/Default.aspx but not for just XYZ.COM.

Any help on this would be appreciated.

 

 

 

 

May 24, 2010 at 9:59 PM

I guess I found the solution to my problem. Replacing the following method

// create GenericPrincipal and set it on Context.User
        private static void SetPrincipal(string username)
        {
            // create principal and set Context.User
            GenericIdentity id = new GenericIdentity(username, "CustomBasic");
            GenericPrincipal p = new GenericPrincipal(id, null);
            HttpContext.Current.User = p;
        }

with the below function resolved the issue.

// create GenericPrincipal and set it on Context.User
        private static void SetPrincipal(string username, string authHeader)
        {
            // create principal and set Context.User
            GenericIdentity id = new GenericIdentity(username, authHeader);
            GenericPrincipal p = new GenericPrincipal(id, null);
            HttpContext.Current.User = p;
        }