简体   繁体   English

为 Azure MVC Web 应用程序获取应用程序 URL 以与 webhook 一起使用

[英]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.

相关问题 Azure Blob存储-MVC Web应用程序-是否可以不通过MVC Web应用程序直接上传到Azure Blob存储中? - Azure Blob Storage - MVC Web Application - Is there a way to upload directly into Azure Blob Storage without going through the MVC web app? MVC Web 应用程序 - Azure AD 和外部帐户 - MVC Web App - Azure AD and External Account 在MVC Web应用程序中使用URL令牌对用户进行身份验证 - Authenticate user with a URL token in an MVC web application Azure身份验证Web应用程序localhost答复URL - azure authentication web app localhost reply url Web应用程序内部的Azure远程应用程序 - Azure Remote App inside my Web Application Azure应用程序日志记录不适用于我的Web App - Azure Application Logging not working for my Web App MVC Web应用程序中的应用程序变量刷新 - Application variable refresh in an mvc web app 如何获取 azure web app url https ssl 证书到期日期? - How to get the azure web app url https ssl certificate expiry date? 直接使用Azure Web App中的应用程序设置,而不是appsettings.Production.json - Use Application settings from Azure Web App directly, not from appsettings.Production.json 如何将PrincipalContext与MVC Web应用程序一起使用 - How to use PrincipalContext with MVC Web Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM