【发布时间】:2015-12-16 22:05:41
【问题描述】:
我正在开发一个带有 AngularJS 前端的 ASP.NET MVC 应用程序,它在从 Visual Studio/iis express 运行时运行良好,但当我尝试发布它以便其他用户可以访问它时效果不是很好(例如,在浏览器中导航到 http://server/application)。我在服务器上配置了 IIS,以便 http://server/application 指向一个“应用程序”文件夹,该文件夹的结构如下:
application
app
areas
foundation
main
layout
layout.html
bin
Content
fonts
Scripts
Templates
Views
Shared
_Layout.cshtml
Index.cshtml
Logs
Global.asax
web.config
初始页面 Index.cshtml(在 Views/Shared/ 下)已加载,但包含以下内容:
<div ng-include="'app/main/layout/layout.html'"></div>
返回 500.24 - 内部服务器错误。
如果我将 ng-include 更改为:
<div ng-include="'application/app/main/layout/layout.html'"></div>
然后发布的应用程序可以工作,但从 Visual Studio/iis express 运行它会返回 404.0 - 尝试加载该 layout.html 文件时未找到响应,我假设是因为它运行时没有父“应用程序”文件夹使用iisexpress。
我确实设法通过将已发布的应用程序文件夹的内容复制到服务器的 C:\inetpub\wwwroot 文件夹来使已发布的应用程序在某一时刻正常工作,但这似乎不是一个合适的解决方案,那么最好的方法是通知 Angular 查找此 ng-include 的正确位置?
【问题讨论】:
标签: angularjs asp.net-mvc iis-7.5