I’m clearly missing the concept of routing – for an experiment I’ve set the route as
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Standard",
"{devicetype}/{devicesub}/{language}/{culture}/{controller}/{action}/{id}",
new
{
devicetype = "pc",
devicesub = "def",
language = "en",
culture = "int",
controller = "Home",
action = "Index",
id = ""
}
);
My index page is in Views/pc/def/en/int/Home
When I run it I get an error searching for /Home/Index.aspx
It seems to still use the default structure and not my more complex one – what am I not understanding?
So, the relevant lines if your controller simply ends in
return View()orreturn View(modelData)are:All URLs matching your above route will land there, unless your URL is for something like /pc/def/en/int/Widgets, in which case you will route to WidgetsController/index.
It sounds like you want to have different views for the same action. If you want to have different views depending on the parameters passed to your controller, you can do that. You need to be explicit about it when you return your ViewResult. You can
return View("SpecialView",model)and the view engine will look for SpecialView.aspx in your controller’s view directory. Of course, “SpecialView” could be replaced with an appropriate string for your app, and could be generated programmatically if it makes sense.