0 Replies - 309 Views - Last Post: 12 July 2019 - 12:09 PM Rate Topic: -----

#1 Exceedinglife   User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 219
  • Joined: 01-July 12

MVC 2 Controllers creating correct routes so both work properly

Posted 12 July 2019 - 12:09 PM

I currently have 2 controllers in my project. My navigation bar uses @Html.ActionLinks and I have the actionlink pick the action and the controller. For some reason the actions are correct but it doesn’t always choose the controller. So im guessing this is something to do with my roureconfig? I been trying to make it choose the correct controller or having it choose ether one wth {controller}/{action} but still I haven’t had any luck

I have a PartsController and a OrderStatusController. When I click on my parts actionlinks they all work, but when I click on my orderstatus action link it goes “parts”, “OrderIndex” even tho I have it specifically saying “OrderStatus”, “OrderIndex” any idea why here are some of my configs I tried?

 public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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



            // OrderStatus/{action}/{id}
            //routes.MapRoute(
            //    name: "OrderStatus",
            //    url: "{OrderStatus}/{action}/{id}",
            //    defaults: new { controller = "OrderStatus", action = "OrderIndex", id = UrlParameter.Optional }
            //);

            //// Parts/Index
            //routes.MapRoute(
            //    name: "Parts_Index",
            //    url: "{Parts}/{Index}/{id}",
            //    defaults: new { controller = "Parts", action = "Index", id = UrlParameter.Optional }
            //);

            // Parts/Index          (Home Page)
            routes.MapRoute(
               name: "Default",
               url: "{controller}/{action}/{id}",
               defaults: new { controller = "Parts", action = "Index", id = UrlParameter.Optional }
            );
:code:

This post has been edited by modi123_1: 12 July 2019 - 12:42 PM
Reason for edit:: In the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Page 1 of 1