[英]Controller action alias in ASP.NET MVC CORE
I have an action called /Telemetries/Page2 .我有一个名为/Telemetries/Page2 的操作。 I wish that /Telemetries/Index was an alias of the aforementioned action.
我希望/Telemetries/Index是上述操作的别名。
I added to startup.cs/Configure the following lines:我在startup.cs/Configure 中添加了以下几行:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "alias_route_home",
template: "Telemetries/Index",
defaults: new { controller = "Telemetries", action = "Page2" });
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "alias_route_events",
template: "Events/Index",
defaults: new { controller = "Events", action = "Pagina5" });
});
and it works!它有效!
app.UseMvc(routes =>
{
routes.MapRoute(
name: "alias_route",
template: "Telemetries/Index",
defaults: new { controller = "Telemetries", action = "Page2" });
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.