2017-04-06 11 views
1

Ich habe ein paar Situationen mit meinem Routing, denke ich. Ich versuche eine Url.Action dafür zu verwenden, aber es funktioniert nicht so, wie ich es mir erhofft habe. Wahrscheinlich etwas Kleines, das ich einfach vermisse?ASP MVC Routing-Problem

Ich sitze auf http://localhost:63061/service, in der Benutzeroberfläche gibt es eine Schaltfläche. Sobald ich darauf klicke, will ich es zu http://localhost:63061/partdispatch

bringen

Scheint ganz einfach, oder? aber aus irgendeinem Grund habe ich immer wieder die falschen Wege.

onclick="window.location.href = '@Url.Action("PartDispatch", "mainmenu")';" 

Routing-Einstellungen:

routes.MapRoute(
       name: "Default", 
       url: "{controller}/{action}/{id}", 
       defaults: new { controller = "MainMenu", action = "Index", id = UrlParameter.Optional } 
+0

So rufen Sie Index-Methode von partdispatch Controller Right ?? –

+0

Ich möchte zum localhost/partdispatch ja gehen. –

+0

@BasantaMatia Erwähnen Sie dies in einer Antwort Ich werde Sie als Antwort abstimmen. Wirklich einfach. –

Antwort

1

Dies ist, wie ich es tue,

onclick="window.location = "../PartDispatch/Index";" 

Oder-else

onclick="window.location.href = '@Url.Action("Index", "PartDispatch")';" 

Hoffe, es hilft :)