繁体   English   中英

我可以在我的 asp.net mvc 核心中的根站点的 url 中添加一个 static 名称吗

[英]Can i add a static name inside the url for the root site inside my asp.net mvc core

I am working on an asp.net mvc core web application, and currently when i access the root url it will be https://localhost:44363/ which represents https://localhost:44363/home/index . 但我的问题是我是否可以在 url 中为根添加一个 static 名称(我们的公司名称),所以它将是https://localhost:44363/OurCompnayName/home/index ? 我可以修改路由以实现此目的或使用其他技术吗?

public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {

    app.UseRouting();

    app.UseEndpoints(endpoints => {

        //http://localhost:5000/shop            -> Products.Index()
        //http://localhost:5000/shop/newest     -> Products.Newest()
        endpoints.MapControllerRoute(
            name: "shop",
            pattern: "shop/{action=Index}",
            defaults: new { controller = "Products" });

        //http://localhost:5000/company         -> Home.Index()
        endpoints.MapControllerRoute(
            name: "company",
            pattern: "company/{controller=Home}/{action=Index}/{id?}");

        //http://localhost:5000                 -> Home.Index()
        //You should allow default route just in case. Otherwise the base url returns 404
        endpoints.MapControllerRoute(
            name: "default",
            pattern: "{controller=Home}/{action=Index}/{id?}");
    });
}

路由到 ASP.NET 核心中的 controller 动作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM