I am new to web apps with asp.net, I have tried to map my own url and ran into some issues. I have the following code
//controller
public class CuisineController : Controller
{
//
// GET: /Cuisine/
public ActionResult Search()
{
return Content("Cuisine");
}
//Global.asax.cs
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathinfo}");
routes.MapRoute(
"Cuisine",
"Cuisine/{name}",
new { controller = "Cuisine", action = "Search", name = UrlParameter.Optional }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", aciton = "Index", id = UrlParameter.Optional}
);
}
}
I know this is extremely basic code, but everytime i run it with the url ~/cuisine/{name} I get an 404 error? Can someone please tell me why? Thanks!
public ActionResult Search(string name) {..then/Cuisine/Indianwill navigate to theSearchmethod and the name parameter will be "Indian"