ASP.NET MVC4 Redirect to login page

前端 未结 6 1226
再見小時候
再見小時候 2020-12-09 15:53

I\'m creating a web application using ASP.NET MVC 4 and C#.

I want all users to be logged in before using application.

I\'m using ASP.NET Membership with a c

6条回答
  •  悲哀的现实
    2020-12-09 16:25

    I know this question already has an answer but if the intention is to lock down the whole app except for a select few controller actions then I feel like this is a better solution ...

    In the startup / init for your app add ...

    httpConfig.filters.Add(new AuthorizeAttribute());
    

    ... then on actions you DONT want to secure ...

    [AllowAnonymous]
    public ActionResult Hello() { return View(); }
    

提交回复
热议问题