发布Angular 5 + .NET Core Web API时为空白页 [英] Blank page when publishing Angular 5 + .NET Core Web API

查看:91
本文介绍了发布Angular 5 + .NET Core Web API时为空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Angular 5应用程序和.NET Core Web Api发布到同一服务器(带有.NET Core捆绑包的IIS),但是当我启动它时,它仅显示一个空白页(没有控制台错误或日志)错误).Web API可以正常工作(已经过邮递员测试),所以我猜测这可能是路由问题.angular 5应用程序是使用Angular-Cli创建的全新应用程序,并使用

I tried to publish an Angular 5 app and a .NET Core Web Api to the same server (IIS with .NET Core bundle), however when I start it up, it just shows a blank page (no console errors or log errors). The Web API works (tested with postman), so I'm guessing it might be a routing issue. The angular 5 app is a fresh one created with Angular-Cli and build to production using

ng build --prod ,然后将dist文件夹的内容复制到wwwroot

ng build --prod and then copied the content of the dist folder over into wwwroot

.NET Core Web Api还是一个仅具有基本GET请求的新鲜API,使用以下方式发布:

The .NET Core Web Api is also a fresh API with just a basic GET request, published using:

dotnet publish --self-contained -r win-x64 -c Release

,然后将内容复制到wwwroot,这意味着所有角度文件和.net核心文件都位于同一目录中.我没有碰过web.config.

and then copied the content into wwwroot, which means all of angular files and .net core files are in same directory. I haven't touched the web.config.

如果我只发布有角度的应用程序,那么它将起作用.

If I only publish the angular app it works.

我在这里想念什么?

推荐答案

转到已发布的角度应用程序的index.html并找到

Go to the index.html of your published angular app and find

<base href="/">

将其更改为

<base href="">

这篇关于发布Angular 5 + .NET Core Web API时为空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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