【发布时间】:2018-01-19 00:35:00
【问题描述】:
我正在尝试在 IIS 上配置 Angular/ASP.NET 5 应用程序以支持深度链接,以便诸如 domain.com/article/title-slug 之类的 URL 工作
我已使用 IIS 重写模块将以下代码添加到我的 web.config:
<rewrite>
<rules>
<rule name="redirect all" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="wwwroot/index.html" appendQueryString="true" />
</rule>
</rules>
</rewrite>
我的问题是我的网站不再加载,我有一个空白屏幕,网络选项卡中没有任何内容,也没有来源。
我的 inetpub\site\ 文件夹是 dotnet core publish 文件夹的根目录,并且我在 inetput\site\wwwroot 中有角度构建资产
我的基本 href 是 = "/",没有重写代码一切正常。
最后,我尝试将我的重写 URL 更改为
<action type="Rewrite" url="/index.html" appendQueryString="true" />
然后我开始收到错误:
inline.f137c7f1f4e2a52a2fb9.bundle.js:1 Uncaught SyntaxError: Unexpected token <
polyfills.25e42e2a7a0746e9ff75.bundle.js:1 Uncaught SyntaxError: Unexpected token <
main.0d9f8e7be2ccd1472551.bundle.js:1 Uncaught SyntaxError: Unexpected token <
【问题讨论】:
-
您的
Startup.cs文件是什么样的? -
根据
SyntaxError: Unexpected token <,我想说您收到的是错误页面的内容,而不是预期的 JS 捆绑包 - 对您的设置一无所知,我只想问您是否可以检查 @ 987654326@内容不知何故..?顺便说一句,在我的设置中,只有<action type="Rewrite" url="/" appendQueryString="true" />(url 参数只有"/")就足够了,不过它是基于 OWIN 的完整 ASP.NET,而不是 Core。 -
@Brad 我的 startup.cs 很大 - 哪些特定部分会有所帮助?
标签: angular iis asp.net-core