首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >angular 2应用发布在.net主机上不起作用

angular 2应用发布在.net主机上不起作用
EN

Stack Overflow用户
提问于 2018-01-10 04:19:55
回答 1查看 463关注 0票数 0

你好,我正在尝试将我的angular 4应用程序发布到我的.net服务器上

我做了ng构建,得到了dist文件。

然后,我将dist文件中的文件发布到ftp根文件夹( httpdocs )。

当我发布和打开网站时,我在控制台上得到这个错误

代码语言:javascript
运行
复制
/inline.bundle.js Failed to load resource: net::ERR_CONNECTION_RESET
/polyfills.bundle.js Failed to load resource: net::ERR_CONNECTION_RESET
/styles.bundle.js Failed to load resource: net::ERR_CONNECTION_RESET
/scripts.bundle.js Failed to load resource: net::ERR_CONNECTION_RESET
/vendor.bundle.js Failed to load resource: net::ERR_CONNECTION_RESET
/main.bundle.js Failed to load resource: net::ERR_CONNECTION_RESET

我尝试在index.html文件中将基本href从= '/‘替换为’‘,但不起作用

我到底该怎么做呢?你怎么看?

我的index.html文件

代码语言:javascript
运行
复制
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Ne Nerede ?</title>
  <base href="">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="oneriyorum.ico">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <link rel="stylesheet" href="node_modules/ladda/dist/ladda.min.css">
  <script>

  </script>
</head>
<body class="hold-transition login-page">
<app-root></app-root>
<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="polyfills.bundle.js"></script>
<script type="text/javascript" src="styles.bundle.js"></script>
<script type="text/javascript" src="scripts.bundle.js"></script>
<script type="text/javascript" src="vendor.bundle.js"></script>
<script type="text/javascript" src="main.bundle.js"></script>
</body>
</html>
EN

回答 1

Stack Overflow用户

发布于 2018-01-10 16:00:43

基本上你唯一要做的就是

1.-创建新的项目Web API,Core2.0为空2.-更改startup.cs的函数配置,添加UseDefaultFiles和useStaticFiles

代码语言:javascript
运行
复制
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    app.UseDefaultFiles();
    app.UseStaticFiles();
}

2.-复制wwwroot中的"dist“文件夹

3.-你的index.html会是这样的

代码语言:javascript
运行
复制
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>MyApp</title>
    <base href="/">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <link href="styles.e85e86d6d65752737800.bundle.css" rel="stylesheet" />
</head>
<body>
    <app-root>Loading..</app-root>
    <script type="text/javascript" src="inline.1aea26911fb58219f5a8.bundle.js"></script>
    <script type="text/javascript" src="polyfills.ad37cd45a71cb38eee76.bundle.js"></script>
    <script type="text/javascript" src="main.d1e85e225566be5f9e29.bundle.js"></script>
</body>
</html>

4.-发布您的项目

(您可以在www.codeproject.com中查看此链接以获得更完整的答案)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48176085

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档