1、首先,我是在VS中開發的angular 所以理論上直接復制程序到服務器,然后建立個站點就完成了,但實際還需要一些設置!呵呵~好坑
2、internet信息服務管理器,打開”MIME類型“。點擊添加,擴展名寫【.json】MIME類型寫【application/x-javascript】,因為多語言需要用到json文件。
3、在Web.config中增加下面代碼,因為在IIS中運行需要這個路由的解析:
<system.webServer> <rewrite> <rules> <rule name="Angular Routes" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite> </system.webServer>
4、增加默認文件index.html 要不路由會出問題,然后帶來一些莫名其妙的問題。
5、如果報告權限之類的錯誤請按下圖設置。
6、Webapi Put 和Delete 訪問不允許
web.config中system.webServer標簽增加:
<system.webServer> <modules runAllManagedModulesForAllRequests="true" runManagedModulesForWebDavRequests="true" > <remove name="WebDAVModule" /> </modules> </system.webServer>
angular練習網站:
http://www.cxd9.com:84/index.html