不能直接獲取url 使用擴展屬性 進行實現
public static class HttpRequestExtensions
{
public static string GetRequestUrl(this HttpRequest source)
{
return $"{source.PathBase}{source.Path}{source.QueryString}";
}
}
引用 using Microsoft.AspNetCore.Http
