I want to link to a controller with actually specifying the action parameter. I'm pretty sure this is possible. And got the concept from here:
http://www.asp.net/mvc/tutorials/controllers-and-routing/creating-a-route-constraint-cs
These are the two links:
https://localhost/mvcapplication1/customer/order/index/6463 (WORKS)
https://localhost/mvcapplication1/customer/order/6463 (WANT THIS)
I specified a special rout for this controller (Customer_orders).
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Customer_orders",
"Customer/Order/{orderId}",
new { controller = "MvcApplication1.Areas.Customer.Controllers.Order", action = "Index" },
new[] { "MvcApplication1.Areas.Customer.Controllers" } // only map routes to controllers in the specified namespace
);
context.MapRoute(
"Customer_default",
"Customer/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new[] { "MvcApplication1.Areas.Customer.Controllers" } // only map routes to controllers in the specified namespace
);
}
And this is my controller with the namespace:
namespace MvcApplication1.Areas.Customer.Controllers
{
[Authorize]
public partial class OrderController : SupertextController
{
I've also enabled the Route Debugger and according to that my routes are ok. So why do I get a "The resource cannot be found."? Specially since it works if I add "index" to the URL.