I have default routing:
routes.MapRoute(
"Shortie",
"{controller}/{id}",
new { controller = "Ettan", action = "Index", id = "id" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Ettan", action = "Index", id = UrlParameter.Optional }
);
I have a controller: NewsController. It has one method, for example:
public ActionResult Index(int id)
{
...
}
If I look through / News / Index / 123, it works. / News / 123 works. However, / News / Index? Id = 123 no (he cannot find any method named "index", where id is resolved as null). Therefore, it seems to me that I do not have enough understanding about how the router and the model node work together.
The reason for the request is that I want to have a drop-down list with different news sources with the parameter "id". Therefore, I can choose one news source (for example, "sport", id = 123), and it should be redirected to my index method. But I can't get this to work.