[英]Creating a routing in .NET Core 2.2 MVC application
I can't figure it out how to configurate a routing in the startup file.我不知道如何在启动文件中配置路由。
That when you redirect to a view that has another controller the URL doesn't look like:当您重定向到具有另一个 controller 的视图时,URL 看起来不像:
localhost/Success/Success/Success
Where the first Success is the controller, the second Success the View folder and the third Success the name of the View itself.其中第一个 Success 是 controller,第二个 Success 是 View 文件夹,第三个 Success 是 View 本身的名称。
I would like something like this:我想要这样的东西:
localhost/Sucess/Sucess
That the name of the controller is not shown in the URL. controller 的名称未显示在 URL 中。
I'm not using a link in the navigation page but a redirect:我没有在导航页面中使用链接,而是使用重定向:
return Redirect("Success/Success/Success");
startup.cs:启动.cs:
routes.MapRoute(name: "success", template: "{controller=Success}/{action=Index}/{id?}");
Try this:尝试这个:
routes.MapRoute(
name: "default",
template: "{controller=Success}/{action=Index}/{id?}");
Try this - you can have multiple routes, but be aware they are order specific.试试这个 - 你可以有多个路线,但要注意它们是特定于订单的。
routes.MapRoute(
name: "default1",
template: "{controller=Success}/{action=Index}/{id?}");
routes.MapRoute(
name: "default2",
template: "{controller=Home}/{action=Index}/{id?}");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.