jsg
jsg

Reputation: 1264

Form authentication except for one page

Hi I'm creating a small site with MVC, I've got about three pages, I'm trying to allow access for all users on a certain page. The page is created in my "HomeController index".

<system.web>
  <authentication mode="Forms">
    <forms defaultUrl="~/" loginUrl="~/Account/Login" name="Test" timeout="10080">
    </forms>
   </authentication>
</system.web>
</system.web>
  <location path="Home">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
<system.webServer>

This is my web config but it still redirects me when i try to go on /home

Upvotes: 1

Views: 286

Answers (1)

Alex
Alex

Reputation: 38529

Add the [AllowAnonymous] attribute above your controller action.

public class HomeController : Controller 
{
     [AllowAnonymous]
     public ActionResult Index()
     {

     }
}

Upvotes: 1

Related Questions