Translate

Tuesday 24 January 2017

Where do you call the config files in MVC?

Generally, We are calling the config files from Application_Start()

using System.Web.Optimization;

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

Is it possible to disable authorization on one action in an MVC controller?

You can add [Authorize] To the controller class, and then add [AllowAnonymous] to the single action you don't want to be authorized. Example:
[Authorize]
    public class AccountController : Controller
    {
        public ActionResult Profile()
        {
            return View();
        }

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