asp.net-core - 如何在asp.net core 1.0中获取当前的url

标签 asp.net-core asp.net-core-mvc asp.net-core-1.0

在以前版本的asp.net中,我们可以使用

@Request.Url.AbsoluteUri

但似乎已经改变了。我们如何在 ASP.NET Core 1.0 中做到这一点?

最佳答案

您必须分别获取主机和路径。

 @Context.Request.Host
 @Context.Request.Path

关于asp.net-core - 如何在asp.net core 1.0中获取当前的url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38437005/

相关文章:

azure - 在 Service Fabric 集群上发布应用程序后 HttpContext.Session 为空

asp.net - .NET Core IoC RegisterAssemblyTypes等效项

asp.net-core-mvc - 如何在 .NET Core 5 MVC 中使用 RouteOptions? (强制使用小写 URL 等)

asp.net - 在 ASP.net Core 中填充下拉列表

c# - Jwt 代码不适用于 .NET Core 2

c# - 具有带参数的虚拟测试方法的 xUnit 抽象测试类

asp.net-core - ASP.Net Web Api Core - 基于查询字符串参数的操作路由

c# - 搜索功能在 Asp.net Core 中不起作用

asp.net-mvc - 在 ASP.NET Core 1.0 中发布后修改 appsettings.Production.json 文件?

c# - .NET Core .csproj 输出路径无法正常工作