我有一个ASP.NET核心应用程序在URL下托管为Azure Web应用程序:
https://my-webapp-url.azurewebsites.net/
这是我的Web配置:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1048576000" />
</requestFiltering>
</security>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".My.WebApp.dll" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" />
</system.webServer>
</configuration>
任何用户都可以访问:
-
https://my-webapp-url.azurewebsites.net/info
页面查看我的应用的健康状态 -
https://my-webapp-url.azurewebsites.net/swagger
页面查看我的应用程序的API文档
我的问题是:
- 需要做什么才能允许用户访问像
https://my-webapp-url.azurewebsites.net/my-extra-file.html
这样的硬编码路径,以便在请求此URL时,HTML页面将返回?
当前,如果我在Web应用程序的wwwroot
DIR中有my-extra-file.html
,并且尝试访问https://my-webapp-url.azurewebsites.net/my-extra-file.html
,则获得404.0。
预先感谢您,对不起。
我将总结并作为答复发布。
使用ASP.NET Core MVC应用程序时,需要在Startup
类的Configure
中添加app.UseStaticFiles();
。因此Web服务器可以为HTML,CSS,JavaScript和Image等静态文件提供服务。
然后在wwwroot
文件夹下创建.html文件,您将访问它。