我需要为我的HTML5应用程序的URL重写提供帮助,该应用程序位于IIS上。URL重写影响来自API的数据
在我的应用程序中,我有页面列出学校。学校数据(JSON)来自C#ASP.net API。我通过使用AngularJS($ http.Get)获取数据。
当我单独跑步即没有角度路由时,学校页面正常工作。之后我包括角JS路由和主机在我的本地IIS,所有的工作除了学校网页不错的网页,这是唯一的页面我得到来自API的数据,
我的API网址:
http://localhost/ita_calender_api/ita/values
学校网页网址:
http://localhost:8080/Schools
(注意:我的应用程序在8080端口上运行和API是默认值)在Web.config中
URL重写:
<rewrite>
<rules>
<rule name="AngularJS 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="ITA_CALENDER_API/(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
当我加载的网址,浏览器,我发现了学校网页,与500
一件事的状态我没有忘了包括XHR响应: 的CORS访问单单我的学校页:
<location path="web/Schools.html">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="http://localhost/" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
您在使用ASP的Web API或MVC?你有'App_Start/RouteConfig.cs'或'App_Start/WebApiConfig.cs'来管理你的路线吗? – cl3m
@ cl3m确切 – Sankar
我正在使用'App_Start/WebApiConfig.cs'来配置路由... – Sankar