locked
IIS Add Application under MVC RRS feed

  • Question

  • User-1132163444 posted

    Hi,

    I have an MVC app hosted in my local IIS that looks like this http://localhost:81/Home/Login

    But i also have a Web Form that i call "Merchants", i need to place this web form just under the MVC  to make the URL look like this http://localhost:81/Merchants

    My problem is IIS is trying to look into the MVC controller for the "Merchants" which does not exist, i want hopefully if possible that if the URL points to http://localhost:81/Merchants it will go to the Web Form, otherwise it will go the the usual Controller.

    I hope someone can help me,

    Thanks

    Tuesday, January 9, 2018 1:33 AM

Answers

  • User283571144 posted

    Hi johnjalani,

    I have an MVC app hosted in my local IIS that looks like this http://localhost:81/Home/Login

    But i also have a Web Form that i call "Merchants", i need to place this web form just under the MVC  to make the URL look like this http://localhost:81/Merchants

    My problem is IIS is trying to look into the MVC controller for the "Merchants" which does not exist, i want hopefully if possible that if the URL points to http://localhost:81/Merchants it will go to the Web Form, otherwise it will go the the usual Controller.

    According to your description, I suggest you could consider changing the RegisterRoutes method in MVC with adding a new route.

    Codes as below:

            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
                routes.MapPageRoute("Merchants",
                       "Merchants",
                        "~/Merchants.aspx");
    
                routes.MapRoute(
                   name: "Default",
                   url: "{controller}/{action}/{id}",
                   defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
               );
     
    
    
            }

    After adding this routes, the application will firstly check the url is "xxxxxx/Merchants", if it is end with "Merchants", it will firstly redirect the page to "Merchants.aspx".

    Then it will use the second routes to map the mvc controller.

    More details about how to use route for web form, you could refer to this article.

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 10, 2018 2:17 AM