[英]Angular App Won't Load After Publishing On IE11
我目前正在 Angular 中開發一個帶有 ASP.NET 后端的應用程序。 我已將項目配置為在 IE11 中本地正常工作(更新 polyfill、瀏覽器列表並添加 ES5 TsConfig 文件),但是當我通過 IIS 將其發布到服務器時,頁面將無法加載並停留在“正在加載.. .”
為了測試發布,我嘗試將默認的 Angular/ASP.NET 應用發布到相同的結果。
控制台顯示四個錯誤:
SCRIPT1002: Syntax error
runtime.458556a34b891ea32398.js (1,1)
SCRIPT1002: Syntax error
polyfills-es5.7119ad0e4b3aeae98a0b.js (1,1)
SCRIPT1002: Syntax error
polyfills.4efda4a4618e08b621be.js (1,1)
SCRIPT1002: Syntax error
main.59969322f93fb24d6bee.js (1,1)
polyfills.ts
import 'classlist.js';
import 'web-animations-js';
import 'zone.js/dist/zone';
網頁配置
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
<defaultDocument enabled="true">
<files>
<add value="ClientApp/dist/index.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
您的應用程序可能會在 IE11 中引發錯誤,即使它在其他瀏覽器中運行良好。 Angular 應用程序不工作的原因可能有很多,包括:
polyfills.ts
。請參閱: https : //medium.com/better-programming/how-to-fix-your-angular-app-when-its-not-working-in-ie11-eb24cb6d9920
感謝@Deepak-MSFT 的回答,結果我沒有在主機上安裝.NET Hosting Bundle 。 一旦我安裝了它,網站就會按預期顯示——除了一些與我在這里談論的內容無關的問題。
對於那些好奇的人,我遇到了數據庫連接字符串的問題,我發現服務器上托管了另一個項目並修改了它的連接字符串: data source=[database];initial catalog=[table];persist security info=True;user id=[user id];password=[password];MultipleActiveResultSets=True;App=EntityFramework
我還刪除了我創建的web.config
文件,因為它可能會妨礙發布期間生成的文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.