Area Routes in ASP.NET MVC?

1

I'm working with areas but it is not working the route and I created 2 areas , inside one I created a folder called Cadastros and inside the other a folder called Tabelas .

RegistrationsAreaRegistration.cs

namespace Projeto01.Areas.Cadastros
{
    public class CadastrosAreaRegistration : AreaRegistration 
    {
        public override string AreaName 
        {
            get 
            {
                return "Cadastros";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context) 
        {
            context.MapRoute(
                "Cadastros_default",
                "Cadastros/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}

TablesAreaRegistration.cs

namespace Projeto01.Areas.Tabelas
{
    public class TabelasAreaRegistration : AreaRegistration 
    {
        public override string AreaName 
        {
            get 
            {
                return "Tabelas";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context) 
        {
            context.MapRoute(
                "Tabelas_default",
                "Tabelas/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}

My question is, when accessing the system, I can access the controllers of the Registry, but when clicking on Products in the Area Tables, the URL tries to call the same with the Area Register, is not changing to Tables, Can anyone help me?

Layout with the application menu that calls the views

<ul class="nav nav-pills nav-stacked">
  <li id="liHome" role="presentation" class="active"><a href="#">Home</a></li>
  <li id="liCategorias" role="presentation">@Html.ActionLink("Categorias", "Index", "Categorias")</li>
  <li id="liFabricantes" role="presentation">@Html.ActionLink("Fabricantes", "Index", "Fabricantes")</li>
  <li id="liProdutos" role="presentation">@Html.ActionLink("Produtos", "Index", "Produtos")</li>
 </ul>
    
asked by anonymous 30.07.2017 / 04:11

1 answer

1

To access the route of an area in Asp.Net MVC, use the following Razor directive:

Html.ActionLink("Link Text", "ActionName", "ControllerName", new { Area = "NomeArea" }, new{}) 
    
30.07.2017 / 18:14