2
I am trying to set a route using area as follows:
At 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 on Admaregistration.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 }
);
}
}
Entradadeuniformescontroller.Cs which 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
Returns this error:
I’m doing something wrong or missing something?