【发布时间】:2015-02-09 10:16:46
【问题描述】:
我有一个 SPA + WebAPI 应用程序,它们都在同一个项目中。我只希望 WebAPI 应用程序处理来自目录“api”的请求。所以 api 下的任何东西都将由服务器处理,其他一切都将由 Angular SPA 处理。
我现在有
<rewrite>
<rules>
<rule name="AngularJS" 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>
这工作正常,除非我转到 URL
http://localhost/customers/2(它会加载文档,但由于上面的重定向规则,所有资源都以错误的 mime 类型输入)
URL http://localhost/customers 工作正常将由我的 SPA 应用程序路由
除了来自 API 目录下的请求之外,如何将所有内容重定向到我的 SPA?
【问题讨论】:
-
您找到解决此问题的方法了吗?遇到完全相同的困境