I'm trying to set up a route using area as follows:
No RouteConfig.cs
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
I created an area called "Adm" and AdmAreaRegistration.cs is as follows:
public class AdmAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Adm";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Adm_default1",
"Adm/{controller}/{action}/{id}-{descricao}",
new {controller = "EntradaDeUniformes", action = "Exibir"}
);
context.MapRoute(
"Adm_default",
"Adm/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
Uniform InputController.cs that is inside the Adm / Controllers folder
public ActionResult Exibir(int? id, string descricao)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
EntradaDeUniforme entradaDeUniforme = db.EntradaDeUniformes.Find(id);
if (entradaDeUniforme == null)
{
return HttpNotFound();
}
return View(entradaDeUniforme);
}
But when I try to pass:
http://localhost/escola/Adm/EntradaDeUniformes/Exibir/1-Calça-Azul
Return this error:
Am I doing something wrong or missing something?