Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how can i add two page route in mvc?

how can i add two page route in mvc?

Scheduled Pinned Locked Moved ASP.NET
questionasp-netdatabasearchitecturehelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mhd sbt
    wrote on last edited by
    #1

    hi all i want use page mappageroutr in simple mvc project but i cant; my code is:

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

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );
    
            routes.MapRoute(
                "viewstudent", // Route name
                "view/viewstudent", // URL with parameters
                new { controller = "Movie", action = "Select", id = UrlParameter.Optional } // Parameter defaults
                )
                ;
       
        }
    

    if i comment route "viewstudent" or comment route 'Default' my route is correct and work but two routmap with together dosent work! thanks for any help

    D M 2 Replies Last reply
    0
    • M mhd sbt

      hi all i want use page mappageroutr in simple mvc project but i cant; my code is:

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

              routes.MapRoute(
                  "Default", // Route name
                  "{controller}/{action}/{id}", // URL with parameters
                  new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
          );
      
              routes.MapRoute(
                  "viewstudent", // Route name
                  "view/viewstudent", // URL with parameters
                  new { controller = "Movie", action = "Select", id = UrlParameter.Optional } // Parameter defaults
                  )
                  ;
         
          }
      

      if i comment route "viewstudent" or comment route 'Default' my route is correct and work but two routmap with together dosent work! thanks for any help

      D Offline
      D Offline
      Deflinek
      wrote on last edited by
      #2

      Hello. Order of routes matters in MVC so in example above the default route will always hit for viewsudent. Swap them and it should work. Take also a loot at this blog post[^] for debugging MVC routes.

      -- "My software never has bugs. It just develops random features."

      M 1 Reply Last reply
      0
      • D Deflinek

        Hello. Order of routes matters in MVC so in example above the default route will always hit for viewsudent. Swap them and it should work. Take also a loot at this blog post[^] for debugging MVC routes.

        -- "My software never has bugs. It just develops random features."

        M Offline
        M Offline
        mhd sbt
        wrote on last edited by
        #3

        thanks a alot i swap two rout and it worked; also thanks for this usefule link this blog post[^]

        1 Reply Last reply
        0
        • M mhd sbt

          hi all i want use page mappageroutr in simple mvc project but i cant; my code is:

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

                  routes.MapRoute(
                      "Default", // Route name
                      "{controller}/{action}/{id}", // URL with parameters
                      new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
              );
          
                  routes.MapRoute(
                      "viewstudent", // Route name
                      "view/viewstudent", // URL with parameters
                      new { controller = "Movie", action = "Select", id = UrlParameter.Optional } // Parameter defaults
                      )
                      ;
             
              }
          

          if i comment route "viewstudent" or comment route 'Default' my route is correct and work but two routmap with together dosent work! thanks for any help

          M Offline
          M Offline
          Mayank_Gupta_
          wrote on last edited by
          #4

          The "Default" route map should always be placed at the end. Try swapping the two MapRoute and it will work.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups