1
我已經徹底研究過這個項目,在我看來,做正確的事情。但是,它不起作用,所以我的意見一定是錯的!IIS重寫規則無法按預期方式工作
我有一個網站,其中所有的內容都在wwwroot或其他文件夾中。 我想讓HTML5網址正常工作。 該網站提供了5種URL類型。
- 一個空的URL。
- 用於物理文件,例如CSS,HTML或JS文件
- 的URL/API的URL/...訪問資源
- 的URL /的OAuth /認證
- 的HTML5標記URL類型,說/公司簡介
我在web.config中
<rule name="index.html as document root" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="/wwwroot/index.html" />
</rule>
<rule name="static dist files" stopProcessing="true">
<match url="^(.+)$" />
<conditions>
<add input="{APPL_PHYSICAL_PATH}wwwroot\{R:1}" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="/wwwroot/{R:1}" />
</rule>
<rule name="api call" stopProcessing="true">
<match url="^/api/" />
<action type="None"/>
</rule>
<rule name="authorization call" stopProcessing="true">
<match url="^/oauth/token$" />
<action type="None"/>
</rule>
<rule name="reroute html5 to index.html" stopProcessing="true">
<match url="^.+$" />
<action type="Rewrite" url="/wwwroot/index.html" />
</rule>
以下重寫規則我看不到我在做什麼錯。我能找到的關於「stopProcessing」的文檔是不精確的,但我假設它意味着如果規則匹配,不要處理更多規則。
發生的情況是,沒有調用API或用於身份驗證的正確處理 - 通過調試API不被調用,而是將其重寫爲wwwroot/index.html。
我確信我正在做一些非常簡單的事情,但我已經嘗試過所有我能想到的事情。
任何幫助表示讚賞。
服務器正在使用OWIN和JWT,而前端是AngularJS。我正在使用VS2015社區進行開發。