3

so i'm trying to put a forms authentication the problem is i'm getting 401.2 Error when i try to go to my login.aspx page, i'm working with iisexpress

 <authorization>
  <deny users="?"/>
</authorization>

<authentication mode="Forms">
<!--<forms loginUrl="Login.aspx" name=".ASPXFORMSAUTH" path="/"></forms>-->
  <!--<forms loginUrl="Login.aspx" timeout="2880" defaultUrl="/" />-->
</authentication>

I tried to add this but it didn't solve my problem

   <location path="Login.aspx">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>
     <location path="Content">
        <system.web>
          <authorization>
            <allow users="?" />
          </authorization>
        </system.web>
     </location>

  <location path="fonts">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>

  </location>
  <location path="Scripts">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>

I searched and tried several solution but no chance have you any idea?

Osaki
  • 37
  • 10

2 Answers2

0

Simple Forms Authentication from MSDN

<system.web>
  <authentication mode="Forms">
    <forms loginUrl="Login.aspx" name=".ASPXFORMSAUTH">
    </forms>
  </authentication>
  <authorization>
    <deny users="?" />
  </authorization>
</system.web>

very clear and good article I have in bookmarks http://weblogs.asp.net/gurusarkar/setting-authorization-rules-for-a-particular-page-or-folder-in-web-config

makison
  • 373
  • 2
  • 10
  • Hi thanks for the reply i did this but it didn't work – Osaki Nov 18 '15 at 13:09
  • I want to allow everyone even anonymos users to go to the login page but i'm getting the same error – Osaki Nov 18 '15 at 13:13
  • I've updated answer to the simplest config, can you check please how it works if you are trying to access logn.aspx and any other page, to move forward – makison Nov 18 '15 at 14:34
  • while it isn't clear what is going on, take look to your site Features view in the IIS Manager, make sure that ASP.NET section present if so go to Authentication in the IIS section to make sure your config works and Forms Authentication has Enabled status and HTTP 302 Login/Redirect response, also check if you have FormsAuthentication in the IIS Modules – makison Nov 18 '15 at 15:10
  • maybe you have similar issue (ignoring my web.config file and applying different authentication) http://stackoverflow.com/questions/19515890/authentication-issue-when-debugging-in-vs2013-iis-express – makison Nov 18 '15 at 16:02
  • specify in your question that you are using IIS Express - it's key moment, maybe someone else will help you with it – makison Nov 18 '15 at 16:08
0

Finally i made a workarround like this I deleted this part :

<authorization>
  <deny users="?"/>
</authorization>

then I modified the locations tags like this :

<location path="Login.aspx">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>
  <location path="Default.aspx">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>
  <location path="Users.aspx">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
    </system.web>
  </location>
  <location path="Content">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>
  <location path="fonts">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>

  </location>
  <location path="Scripts">
    <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
    </system.web>
  </location>

So when I tru to go to default or users page i'm gettting redirected automatically to login page. I really searched a lot to understand what i'm doing wrong but didn't find out so I'm adopting this solution for the moment.

Osaki
  • 37
  • 10