zoukankan      html  css  js  c++  java
  • runAllManagedModulesForAllRequests 和 invalid url

    有这样的经验, 在本地的 IIS 上网站运行正常,但是发布到服务器上就一堆怪怪的问题 : 

    MVC routing not work
    http://stackoverflow.com/questions/12495346/asp-net-4-5-mvc-4-not-working-on-windows-server-2008-iis-7
    http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html
    Owin not work
    http://stackoverflow.com/questions/23276144/microsoft-owin-host-systemweb-and-still-getting-no-owin-environment-item-was-fou
    AuthorizeAttribute not work
    http://stackoverflow.com/questions/21170269/asp-net-mvc5-application-throwing-nullreferenceexception-when-authorizing
    http://stackoverflow.com/questions/11048863/modules-runallmanagedmodulesforallrequests-true-meaning

    Odata action 404

    等等, 这么多怪怪的问题,都可以用 runAllManagedModulesForAllRequests=”true“ 来解决. 

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" >
        </modules>  
    </system.webServer>

    但这不是个好方法. 因为性能会浪费, 还有一些静态文件的请求可能会被要求验证 (比如图片是可以含有 & 符号的, 但是你设置了这个, 就会被验证成 invalid 了).

    网上有很多替代的方案. 但是我发现在 IIS 8.5 的情况下, 基本上你只要用 vs2015 MVC template 的 webconfig 就不会遇到怪怪的问题了。 

    odata action 404 则需要加一行代码在 webserver handler 里面

          <add name="ExtensionlessUrlHandler-Integrated-4.0Custom" path="/api*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

    另外提一下, IIS 使用的是 RFC 2396 对 url 进行检查 

    http://www.cnblogs.com/shaomeng/p/5171178.html

    要注意图片的路径哦. 

  • 相关阅读:
    回答自己之前的提问!
    阅读《构建之法》第13-17章
    阅读《构建之发》10-12章
    阅读《构建之法 》8,9,10章
    Practise 5.2测试与封装(黑白盒
    Practice5.1 测试与封装5.1
    Practice4 阅读《构建之法》6-7章
    Practice3 阅读《构建之法》1-5章
    “做汉堡”之评价我的队友
    Practice2 结对子之“小学四则运算”
  • 原文地址:https://www.cnblogs.com/keatkeat/p/6154901.html
Copyright © 2011-2022 走看看