title: Allow anonymus users to access only Login and Register page in ASP.NET
body: <p>I'm creating ASP.NET application. I need to make only two pages (login.aspx and register.aspx) visible to anonymous users in default.aspx page.</p>
  
  <p>I tried <a href="https://stackoverflow.com/questions/29168914/allow-anonymus-users-to-access-only-login-and-register-page">Allow anonymus users to access only Login and Register page</a>, but don't know where exactly change for my own code. So any hint? </p>
  
  <p>This is example in my application:</p>
  
  <p><a href="https://i.stack.imgur.com/942Dl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/942Dl.jpg" alt="example"></a> </p>
  
  <p><strong>Web.config</strong> </p>
  
  <pre><code>&lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
    &lt;/configSections&gt;
    &lt;connectionStrings&gt;
      &lt;remove name="CS" /&gt;
      &lt;add name="CS" connectionString="Data Source=NET134;User ID=admin;Password=admin123;Initial Catalog=Reservations;"  providerName="System.Data.SqlClient" /&gt;
    &lt;/connectionStrings&gt;
    &lt;system.web&gt;
      &lt;authentication mode="Forms"&gt;
  
        &lt;!-- Redirect LonginStatus Loginurl to Account/login.aspx --&gt;
  
        &lt;forms loginUrl="Account/Login.aspx" /&gt;
  
      &lt;/authentication&gt;
  
      &lt;compilation debug="true" targetFramework="4.5.2"&gt;
        &lt;assemblies&gt;
          &lt;add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /&gt;
          &lt;add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;
        &lt;/assemblies&gt;
        &lt;buildProviders&gt;
          &lt;add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" /&gt;
        &lt;/buildProviders&gt;
      &lt;/compilation&gt;
      &lt;httpRuntime targetFramework="4.5.2" /&gt;
      &lt;pages&gt;
        &lt;namespaces&gt;
          &lt;add namespace="System.Web.Optimization" /&gt;
          &lt;add namespace="Microsoft.AspNet.Identity" /&gt;
        &lt;/namespaces&gt;
        &lt;controls&gt;
          &lt;add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" /&gt;
        &lt;add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /&gt;&lt;/controls&gt;
      &lt;/pages&gt;
      &lt;membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add
            name="SqlProvider"
            type="System.Web.Security.SqlMembershipProvider"
            connectionStringName="CS"
            applicationName="MyApplication"
            enablePasswordRetrieval="false"
            enablePasswordReset="true"
            requiresQuestionAndAnswer="true"
            requiresUniqueEmail="true"
            passwordFormat="Hashed" /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
      &lt;profile&gt;
        &lt;providers&gt;
          &lt;!--
          ASP.NET Membership Profile is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
          --&gt;
          &lt;clear /&gt;
        &lt;/providers&gt;
      &lt;/profile&gt;
      &lt;roleManager&gt;
        &lt;!--
            ASP.NET Membership Role is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
          --&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
      &lt;!--
              If you are deploying to a cloud environment that has multiple web server instances,
              you should change session state mode from "InProc" to "Custom". In addition,
              change the connection string named "DefaultConnection" to connect to an instance
              of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
        --&gt;
      &lt;sessionState mode="InProc" customProvider="DefaultSessionProvider"&gt;
        &lt;providers&gt;
          &lt;add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" /&gt;
        &lt;/providers&gt;
      &lt;/sessionState&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;modules&gt;
        &lt;remove name="FormsAuthentication" /&gt;
      &lt;/modules&gt;
    &lt;/system.webServer&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security.OAuth" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security.Cookies" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="Microsoft.Owin.Security" culture="neutral" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="mssqllocaldb" /&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
    &lt;system.codedom&gt;
      &lt;compilers&gt;
        &lt;compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /&gt;
        &lt;compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&amp;quot;Web\&amp;quot; /optionInfer+" /&gt;
      &lt;/compilers&gt;
    &lt;/system.codedom&gt;
  &lt;/configuration&gt;
  </code></pre>