如何将公共静态站点托管为Web应用程序? [英] How do I host a public static site as a web app?

查看:133
本文介绍了如何将公共静态站点托管为Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望网址www.example.com显示default.html 通过这个问题,我知道最简单的方法仍然是创建Web应用程序.

I want the url www.example.com to display default.html From this question I understand that the easiest way is still to create a web app.

[如何不做]

我尝试在VS2017中创建解决方案 文件->新建->项目-> .Net Core-> Asp.Net Core Web应用程序->空

I tried creating a solution in VS2017 File->New ->Project -> .Net Core -> Asp.Net Core Web Application-> Empty

然后我将静态文件移至wwwroot并进行了部署 我需要更改什么,以便有人访问该网站时加载default.html?

Then I moved my static files into wwwroot and deployed What do I need to change so that default.html will load when someone goes to the site?

此刻,如果我删除Program类,则会收到一条消息

At the moment if I remove the Program class I get a message

Severity    Code    Description Project File    Line    Suppression State
Error   CS5001  Program does not contain a static 'Main' method suitable for an entry point 

这是可以理解的,因为它是一个Web应用程序,如何将其更改为静态网站?

which is understandable since it is a web application , how do I change it to be a static web site?

[一种更好的方法,在Azure中创建应用.]

[A better way, create the app in Azure.]

我创建了一个新的Web应用程序,并按照

Instead of the above method I created a new web app and followed the advise at this question to paste in index.html.

我现在可以转到网站的Azure URL,并显示正确的内容.

I can now go to the Azure url for the site and the correct content displays.

下一步,我需要使example.com正常工作.

Next I need to get example.com to work.

我将DNS的www的CName记录添加到站点的URL中,并且还去了Azure中的自定义域"来添加我的域名.

I added the CName record for www in my DNS with the url for the site, and I also went to Custom Domains in Azure to add my domain name.

但是,当我访问网站时出现以下错误.

However I get the following error when I go to my site.

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.

推荐答案

我最终使它能够正常工作.我一定错过了文档

I got it working in the end. I must have missed a step in the documentation

这篇关于如何将公共静态站点托管为Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆