[英]Get application URL for Azure MVC Web app for use with webhooks
I need to transer the URL of my web app to an external API.我需要将我的 web 应用程序的 URL 传输到外部 API。 The app is an ASP.NET web app.
该应用程序是 ASP.NET web 应用程序。 Can I use the Azure SDKs to obtain this URL somehow?
我可以使用 Azure SDK 以某种方式获取此 URL 吗?
This happens on app startup, so I do not have access to any request context.这发生在应用程序启动时,因此我无权访问任何请求上下文。
You can utilize UriHelper class of the HTTP Extension library, For dot net core you can find the definition here:您可以使用 HTTP 扩展库的 UriHelper class,对于 dot net core,您可以在此处找到定义:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.extensions.urihelper?view=aspnetcore-3.0 https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.extensions.urihelper?view=aspnetcore-3.0
UriHelper.GetDisplayUrl(HttpRequest) Method
Returns the combined components of the request URL in a fully un-escaped form (except for the QueryString) suitable only for display.以仅适用于显示的完全未转义形式(QueryString 除外)返回请求 URL 的组合组件。 This format should not be used in HTTP headers or other HTTP operations.
此格式不应用于 HTTP 标头或其他 HTTP 操作。
UriHelper.GetEncodedUrl(HttpRequest) Method
Returns the combined components of the request URL in a fully escaped form suitable for use in HTTP headers and other HTTP operations.以适用于 HTTP 标头和其他 HTTP 操作的完全转义形式返回请求 URL 的组合组件。
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.extensions.urihelper?view=aspnetcore-2.1 https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.extensions.urihelper?view=aspnetcore-2.1
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.