Skip to content
Loading
Routing pages to allow any controller except home 
  • Hi Sachin
     
    System.ArgumentException: 'A route named 'eNtsaAddToCard' could not be found in the route collection.
    Parameter name: name'
     
    You see what i am trying to raise here, i have 'HomeController' and my dashboard is on HomeController routing. How do i access routing of another controller? I have 'eNtsaAddToCard'  as a controller. See here
    1. // Rooute to AddtoCart.  
    2.          routes.MapRoute(  
    3.              name: "eNtsaPaymentOrders/",  
    4.              url:"add-to-card",  
    5.              defaults:new {controller = "eNtsaAddToCard", action = "eNtsaPaymentOrders", id = UrlParameter.Optional }  
    6.           );  
     
  • "@Url.RouteUrl("eNtsaPaymentOrders")">SuperAdmin
  • // This is causing the above exception.
  • Sachin Singh
    it doesn't matter you want apple or not, inplace of apple what do you want to eat?
    if you don't want to redirect to home controller then on which controller do you want to redirect the request?
     
    for example if you change the routeName to something else it will be redirected to that.
    1. "@Url.RouteUrl("eNtsaPaymentOrders")">SuperAdmin
    2.    
     Now it will be redirected to controller = "eNtsaAddToCard", action = "eNtsaPaymentOrders"
  • Sachin
     
    I want to set the controller that is not routing to Home, 
     
    1. class="submenu">    
    2.                    
    3. "@Url.RouteUrl("OtherController")">eNtsaAddCard
    4. // This is not promping me to it, i notice this _SideBarMenuLayout points to Index(dashbord) this has controller within HomeController    
    5.                    
    6. "#">User-Account
    7.     
    8.    
    9.                  
     
  • Sachin Singh
    could not understand your question , if you want to set a default controller as start controller instead of Home then
    keep the below url template above all other defined url templates in route.config.
    1. routes.MapRoute(    
    2.                 name:"Start",    
    3.                 url:"",   // set url to null 
    4.                 defaults:new {controller= "YourController", action= "SuperAdmin", url = UrlParameter.Optional}    
    5.              );