The route function does not work on the start page

I am trying to implement URL routing in ASP.Net web forms (for the first time) using the solution I found on the website [ download solution ]. The route works except mine Start Page.


For example, if I set Home.aspxurl as the start page, http://localhost:49200/Home.aspxand other pages say that it Modificationsdisplays as http://localhost:49200/Modifications, the route works on other pages.
And if I set Modificationsas the start page, then the url will become http://localhost:49200/Modifications.aspxand Homewill become http://localhost:49200/Home. Why is this?

Global.asax

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;

namespace Test
{
    public class Global : System.Web.HttpApplication
     {

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }

        static void RegisterRoutes(RouteCollection routes)
        {
            routes.MapPageRoute("Home", "Home","~/Home.aspx");
            routes.MapPageRoute("Modifications", "Modifications","~/Modifications.aspx");
            routes.MapPageRoute("AccountClosing", "AccountClosing","~/AccountClosing.aspx");
        }
    }
}

Does anything need to be done in config? The menu is in a format '<%=ResolveUrl("~/Home") %>'.! Please help solve this problem.

+4

Source: https://habr.com/ru/post/1679044/


All Articles