node.js 在 IIS 上部署 Angular 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32719436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 19:18:51  来源:igfitidea点击:

Deploy angular application on IIS

angularjsnode.jsiis-7gulp

提问by Lali

I am working on AngularJs application with node.js. Using gulp, I have created (compiled) my application (appin below image) and got the following directories

我正在使用 node.js 开发 AngularJs 应用程序。使用 gulp,我已经创建(编译)了我的应用程序(app如下图所示)并获得了以下目录

enter image description here

enter image description here

Now I completely struck how to proceed next. I want to host this application over IIS to run and see the pages (in viewsfolder) but I don't know how to host it on IIS.

现在我完全了解下一步如何进行。我想在 IIS 上托管此应用程序以运行并查看页面(在views文件夹中),但我不知道如何在 IIS 上托管它。

I tried thisarticle, but it guides to use express server.

我试过这篇文章,但它指导使用快速服务器。

The issue is, how IIS will figure out that the first page lies in viewsfolder, and even if I use the complete url

问题是,IIS 如何确定第一页位于views文件夹中,即使我使用完整的 url

http://localhost:8078/views/index.html

it shows me all angular code with brackets like {{logginuser}}etc

它向我展示了所有带括号的角度代码,例如{{logginuser}}

EDIT: Do I need web.config file here or not. If yes then how I will define entry point to the application?

编辑:我是否需要这里的 web.config 文件。如果是,那么我将如何定义应用程序的入口点?

回答by Chris Story

Just have to configure a Web Application under a website in IIS and create a custom web.config.

只需在 IIS 中的网站下配置 Web 应用程序并创建自定义 web.config。

  1. In IIS, go to the Default Web Site, right-click and select Add Web Application
  2. Set the Alias to be AngularApp and the Physical Path to be the root of your directory
  3. Add a web.config file at the root of the directory with the following code

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <defaultDocument>
            <files>
                <add value="views/index.html" />
            </files>
        </defaultDocument>
      </system.webServer>
    </configuration>
    
  4. Browse to your new Angular application by going to http://localhost/AngularApp(assuming http binding in IIS).

  1. 在 IIS 中,转到默认网站,右键单击并选择添加 Web 应用程序
  2. 将别名设置为 AngularApp,将物理路径设置为目录的根目录
  3. 使用以下代码在目录的根目录添加一个 web.config 文件

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <defaultDocument>
            <files>
                <add value="views/index.html" />
            </files>
        </defaultDocument>
      </system.webServer>
    </configuration>
    
  4. 通过转至http://localhost/AngularApp(假设 IIS 中的 http 绑定)浏览到您的新 Angular 应用程序。

回答by hannes neukermans

Lost 2 hours with this The solution was to go to WINDOWS FEATURESand check 'static content', under COMMON HTTPfeatures.

用这个丢失了 2 小时解决方案是去WINDOWS FEATURES检查COMMON HTTP功能下的“静态内容” 。

enter image description here

enter image description here

Hope this helps someone.

希望这可以帮助某人。

回答by Ramesh Rajendran

You need set as start page to you main screen (like index.html)

您需要将主屏幕设置为起始页(如 index.html)

How can I set it in IIS?

我如何在IIS中设置它?

Just go to web.config file and add following

只需转到 web.config 文件并添加以下内容

<system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.html" />//Path of your Page
      </files>
    </defaultDocument>
</system.webServer>

More details : How do I set the default page of my application in IIS7?

更多详细信息:如何在 IIS7 中设置应用程序的默认页面?