在 IIS 上部署 Angular 应用程序 [英] Deploy angular application on IIS

查看:23
本文介绍了在 IIS 上部署 Angular 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

现在我完全明白下一步该怎么做.我想通过 IIS 托管此应用程序以运行并查看页面(在 views 文件夹中),但我不知道如何在 IIS 上托管它.

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

我试过 this 文章,但它指导使用 express 服务器.

I tried this article, but it guides to use express server.

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

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

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

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

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

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

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

推荐答案

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

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

  1. 在 IIS 中,转到默认网站,右键单击并选择添加 Web 应用程序
  2. 将 Alias 设置为 AngularApp,将 Physical Path 设置为目录的根目录
  3. 在目录根目录下添加一个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>

  • 通过 http://localhost/AngularApp 浏览到您的新 Angular 应用程序(假设 http 绑定在IIS).

  • Browse to your new Angular application by going to http://localhost/AngularApp (assuming http binding in IIS).

    这篇关于在 IIS 上部署 Angular 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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