MVC 3 Won't Serve Content files from Areas subfolder

前端 未结 1 378
梦毁少年i
梦毁少年i 2021-02-02 02:41

I have an MVC3 application with a couple of areas and a portable area as well (using MVCContrib)

Normally, I keep all my content files under ~/Content and my scripts und

相关标签:
1条回答
  • 2021-02-02 03:12

    So after some sleep and, more importantly, stepping away from the problem I remembered that MVC does in fact offer you protection from people downloading views directly, which led me to remember the Web.config file required in the Areas folder. Sure enough, there's an httphandler that basically sends all requests to the FileNotFound handler.

    All I had to do was drop a web.config file in the content folder I wanted to expose with the following:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>  
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
          <remove name="BlockViewHandler" />     
        </handlers>
      </system.webServer>
    </configuration>
    

    Problem solved.

    0 讨论(0)
提交回复
热议问题