I am trying with no success to do the following :
url:
MyString/MyController1
MyString/MyController2
MyString/MyController3
MyString/
For the first three I am using :
routes.MapRoute(
"MyString/MyController1", // Route name
"MyString/MyController1/{action}/{id}", // URL with parameters
new {controller = "MyController1", action = "Index", id = UrlParameter.Optional},
new string[] {"Core_Web.Controllers.MyString"}
);
and it works perfectly well. My problem arrives when I try to access MyString/.
I have added :
routes.MapRoute(
"Default",
"MyString",
new { controller = "MyString", action = "Index", id = UrlParameter.Optional },
new string[] {"Core_Web.Controllers"}
);
But the call of the url MyString gives :
The resource cannot be found
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /MyString
There is a Controller named MyString in Core_Web.Controllers.
thanks for your help,
[EDIT]
here is my whole code :
the routes:
routes.MapRoute(
"Contabilita",
"Contabilita",
new { controller = "Contabilita", action = "Index" },
new string[] { "Core_Web.Controllers" }
);
routes.MapRoute(
"Contabilita_Controller", // Route name
"Contabilita/{controller}/{action}/{id}", // URL with parameters
new { action = "Index", id = UrlParameter.Optional},
new string[] { "Core_Web.Controllers.Contabilita" }
);
and the controllers:
namespace Core_Web.Controllers
{
public class ControllerContabilitaBase : ControllerBaseSuper
{
....
}
public class ControllerContabilita : ControllerContabilitaBase
{
public ActionResult Index()
{
return View(GetView("Index"));
}
}
}
namespace Core_Web.Controllers.Contabilita
{
public class ImpiantoController : ControllerContabilitaBase
{
...
}
public class LottoController : ControllerContabilitaBase
{
...
}
}
but it does not work either. The url with the controller in it works but not the other one. It gives 404.
am I possibly overlooking something else?
[/Edit]
Try the following route definitions (in that order):
Which should give you the following pattern: