在虚拟目录下运行ASP.NET Boilerplate模板

时间:2018-11-07 07:49:59

标签: javascript iis aspnetboilerplate virtual-directory base-url

我有一个由ASP.NET Boilerplate创建的Angular模板。我已经成功发布了它,并且它在IIS下的网站上可以正常运行。但是,我的客户希望它在虚拟目录下运行,而不是自己在网站上运行。 enter image description here

我更新了 appconfig.json 如下:

{
  "remoteServiceBaseUrl": "http://localhost:8080/Training",
  "appBaseUrl": "http://localhost:8080/Training"
}

,并对 appSettings.json 中的App进行了相同操作:

"App": {
    "ServerRootAddress": "http://localhost:8080/Training/",
    "ClientRootAddress": "http://localhost:8080/Training/",
    "CorsOrigins": "http://localhost:8080/Training"
}

由于某种原因,当我运行该应用程序时,出现以下错误,该错误无法加载某些CSS和JavaScript捆绑包: enter image description here

我已经手动更改了 wwwroot 文件夹中的 index.html ,并将http://localhost:8080/Training/添加到每个href的开头。这样一来,所有这些错误都消失了,现在我只剩下这个错误了:

GET http://localhost:8080/assets/appconfig.json 404 (Not Found)

我认为与 AppPreBootstrap.ts 文件有关,该文件从 appconfig.json 文件读取。

要发布上述应用程序,我是否必须在发布前对应用程序设置进行任何更改?

1 个答案:

答案 0 :(得分:0)

确保 AppPreBootstrap.ts 中的appRootUrl'/'结尾:

private static getApplicationConfig(appRootUrl: string, callback: () => void) {
    appRootUrl += appRootUrl.endsWith('/') ? '' : '/'; // Add this line
    return abp.ajax({
        url: appRootUrl + 'assets/' + environment.appConfig,
        // ...
    }).done(result => {
        // ...
    });
}