ASP.NET Core routing prefix

后端 未结 5 1086
余生分开走
余生分开走 2021-01-17 17:45

I\'m developing an ASP.NET Core application. My application hosted with NGinx on url http://somedomain.com/MyApplication.

I need all requests routed to

5条回答
  •  不知归路
    2021-01-17 17:57

    If you are using MVC, you can try to change the default route format. In Startup.cs replace the line

    app.UseMvc(routes => { routes.MapRoute(name: "default", template: "/{controller=Home}/{action=Index}/{id?}"); });
    

    with this one:

    app.UseMvc(routes => { routes.MapRoute(name: "default", template: "MyApplication/{controller=Home}/{action=Index}/{id?}"); });
    

    Let me know if it's what you need

提交回复
热议问题