大佬教程收集整理的这篇文章主要介绍了如何正确刷新在VS 2015 Web开发环境中运行的AngularJS SPA,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法可以修改我的web.config文件(仅用于本地测试),以便它实际上转到index.html(加载它)然后转到/ home / about状态?
这是我当前的web.config:
<configuration> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web> </configuration>
这个SO answer有关于在web.config上配置URL Rewrite的详细信息:
规则通过:
<system.webServer> <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="^/(api)" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite> </system.webServer>
它假定您的API位于:/ api下,并且对于它找到的任何目录或文件,它按原样使用.
任何其他的,被重写为/将默认文档配置为index.html,将加载SPA.
另请注意,您需要安装URL Rewrite module for IIS(IIS Express doesn’t need the module)
另一个选项是这些轻量级http服务器npm包之一.
John Papa has one: lite-server.它在引擎盖下使用BrowserSync:
以上是大佬教程为你收集整理的如何正确刷新在VS 2015 Web开发环境中运行的AngularJS SPA全部内容,希望文章能够帮你解决如何正确刷新在VS 2015 Web开发环境中运行的AngularJS SPA所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。