如何在ASP.NET Core 3.1 MVC中进行自定义路由

LPLN

我不能在.NET Core 3.1中使用像.NET Core 2.2中那样的简单路由。

.NET Core 3.1中的路由最后更改是什么?

哈米德·哈吉鲁(Hamed Hajiloo)

在.NET 3中,您应该使用端点而不是路由

app.UseStaticFiles();
app.UseRouting();
//other middleware

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
    endpoints.MapRazorPages();
    endpoints.MapHub<MyChatHub>();
    endpoints.MapGrpcService<MyCalculatorService>();
    endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

.NET Core 3 MVC中的自定义路由

如何在ASP.NET Core中进行条件路由?

如何在ASP MVC中进行自定义路由

如何在ASP.NET Core 1 MVC 6中模拟IFormFile进行单元/集成测试?

ASP.NET Core 中的自定义路由

Asp.net Core Api 自定义路由

如何在ASP.Net MVC4和Web API 1项目中进行属性路由?

如何在ASP.NET Core中进行异常处理?

如何在asp.net core 3中添加全局路由前缀?

如何在Asp.net Core MVC(又名Asp.Net 5 RC1)中检查响应cookie?

如何在Asp.net Core 1中创建请求以进行测试

asp.net core mvc 中的自定义授权

ASP.NET Core MVC自定义站点变量

ASP.NET Core 3 MVC端点路由和按路由进行本地化

使用自定义位置时如何在asp.net core mvc中指定视图位置?

如何在ASP.NET Core MVC中自定义Html.DropDownListFor辅助设置名称属性

自定义中间件(或授权),用于ASP.NET Core 3.1 MVC中的特定路由

如何在ASP.NET Core MVC中进行IEnumerable查询?

如何在 ASP.Net Core 3 中使用 UseNodeModules?

如何在.net core 2.0中创建自定义路由控制器

如何在ASP.NET MVC中创建到自定义路由的ActionLink?

如何在ASP.NET Core中测试自定义操作筛选器?

如何在ASP.NET Core中的自定义TagHelper中呈现Razor模板?

如何在ASP.NET Core中使用C#生成自定义键号

如何在ASP.NET Core中实现自定义模型验证?

如何在ASP.NET Core中创建自定义AuthorizeAttribute?

如何在ASP.NET Core中编写自定义actionResult

如何在DI中注册自定义UserManager等-ASP.NET Core 2.1

如何在NSwag(ASP.NET Core)中生成自定义响应示例值?