【发布时间】:2017-12-22 03:53:07
【问题描述】:
我希望网址 www.example.com 显示 default.html 从这个question 我明白最简单的方法仍然是创建一个网络应用程序。
[怎么不做]
我尝试在 VS2017 中创建解决方案 文件->新建->项目->.Net Core->Asp.Net Core Web应用程序->空
然后我将我的静态文件移动到 wwwroot 并部署 我需要更改什么,以便在有人访问该站点时加载 default.html?
目前,如果我删除 Program 类,我会收到一条消息
Severity Code Description Project File Line Suppression State
Error CS5001 Program does not contain a static 'Main' method suitable for an entry point
这是可以理解的,因为它是一个网络应用程序,我如何将其更改为静态网站?
[更好的方法,在 Azure 中创建应用程序。]
我创建了一个新的网络应用程序,而不是上述方法,并按照this question 的建议粘贴 index.html。
我现在可以转到该站点的 Azure url 并显示正确的内容。
接下来我需要让 example.com 工作。
我在我的 DNS 中添加了 www 的 CName 记录以及站点的 url,我还去了 Azure 中的自定义域来添加我的域名。
但是,当我访问我的网站时,出现以下错误。
Error 404 - Web app not found.
The web app you have attempted to reach is not available in this Microsoft Azure App Service region. This could be due to one of several reasons:
1. The web app owner has registered a custom domain to point to the Microsoft Azure App Service, but has not yet configured Azure to recognize it. Click here to read more.
When an app owner wants to use a custom domain with a Microsoft Azure Web Apps web app, Azure needs to be configured to recognize the custom domain name, so that it can route the request to the appropriate server in the region. After registering the domain with a domain provider and configuring a DNS CNAME record to point to the app's Azurewebsites.net address (for example, contoso.azurewebsites.net), the web app owner also needs to go to the Azure Portal and configure the app for the new domain. Click here to learn more about configuring the custom domains for a web app.
【问题讨论】:
-
诀窍是继续前进,直到您可以看到 www.example.com 和 example.com 列在自定义主机名下