ASP.NET MVC `Html.ActionLink` between “Areas”

Strange indeed. Steps that worked perfectly fine for me: Create a new ASP.NET MVC 3 application using the default Visual Studio template Add an area called Admin using Visual Studio designer by right clicking on the project Add new Controller in ~/Areas/Admin/Controllers/MeetsController: public class MeetsController : Controller { public ActionResult Index() { return View(); } … Read more

How can we set authorization for a whole area in ASP.NET MVC?

Web.config-based security should almost never be used in an MVC application. The reason for this is that multiple URLs can potentially hit a controller, and putting these checks in Web.config invariably misses something. Remember – controllers are not associated with areas, routes are associated with areas. The MVC controller factory will happily serve controllers from … Read more

How to use an Area in ASP.NET Core

In order to include an Area in an ASP.NET Core app, first we need to include a conventional route in the Startup.cs file (It’s best to place it before any non-area route): In Startup.cs/Configure method: app.UseMvc(routes => { routes.MapRoute(“areaRoute”, “{area:exists}/{controller=Admin}/{action=Index}/{id?}”); routes.MapRoute( name: “default”, template: “{controller=Home}/{action=Index}/{id?}”); }); Then make a folder named Areas in the app … Read more

Force all Areas to use same Layout

You just have to add a file named: _ViewStart.cshtml Under each area views folder: /Areas/Area1/Views/_ViewStart.cshtml And edit the file to point to the root layout like this: @{ Layout = “~/Views/Shared/_Layout.cshtml”; } In order for this to work, you do not have to specify a value in the view’s layout property, if you do, you … Read more

Having issue with multiple controllers of the same name in my project

The error message contains the recommended solution: “If this is the case, register this route by calling an overload of the ‘MapRoute’ method that takes a ‘namespaces’ parameter.” routes.MapRoute( “Default”, // Route name “{controller}/{action}/{id}”, // URL with parameters new { controller = “Home”, action = “Index”, id = UrlParameter.Optional }, // Parameter defaults new string[] … Read more