0

How to authorize a specific page to be accessed anonymously in asp.net MVC using the web.config?

I know that this could be done using the [Authorize] and [AllowAnonymous] attributes but I was wondering if I can do that directly from the config file.

For example

[Authorize]
public class HomeController : Controller
{
    [AllowAnonymous]
    public ActionResult Index()
    {
        return View();
    }


    public ActionResult TrackingPage()
    {
        return View();
    }


    public ActionResult profile()
    {
        ViewBag.profile = true;
        return View();
    }
    public ActionResult content()
    {
        return View();
    }

} 

If I want to do the same thing from the config file, how that could be done?

Mo Haidar
  • 3,748
  • 6
  • 37
  • 76
  • why you wanna do that? – Arijit Mukherjee Jun 08 '15 at 09:41
  • I am studying the authentication and authorization and I wanna learn the different ways of authentication and authorization? – Mo Haidar Jun 08 '15 at 09:42
  • possible duplicate of [Allow anonymous authentication for a single folder in web.config?](http://stackoverflow.com/questions/10351075/allow-anonymous-authentication-for-a-single-folder-in-web-config) – DavidG Jun 08 '15 at 09:44
  • As far as I know you advance setting you can override the Filter Class and define your own, using web.config i'm not aware of but will surely update me if you find the answer to this. – Arijit Mukherjee Jun 08 '15 at 09:44
  • @DavidG that is for the whole folder but for me I need to make it only for one action method in a controller – Mo Haidar Jun 08 '15 at 09:57

0 Answers0