Form Authentication inside VS 2013

176 views Asked by At

I am using following configuration in my web.config file

<system.web>
    <authentication mode="Forms">
       <forms name=".ASPXFORMSDEMO" loginUrl="Defautl.aspx" protection="All" path="/" timeout="30" />
    </authentication>
    <authorization>
       <deny users ="?" />
       <allow users = "*" />
    </authorization>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
</system.web>

But when I am running the code I get an error

Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server.

As I running it from local host so I am not sure why this error is happening.

If I disable Windows Authentication from project property the above error shows up. If I enable this then I can view any page inside my application without login.

I have commented the code ConfigureAuth inside Startup class.

Edit 1: I have gone through this link

1

There are 1 answers

0
Hirav Sampat On

Try This..

<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <authentication mode="Forms" lockItem="true">
    <forms loginUrl="Login.aspx" name="frmL" slidingExpiration="true" protection="All" defaultUrl="Default.aspx" path="/"/>
</authentication>
</system.web>

<location path="YourDirectoryForAuthorizedUsers">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>