Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit/download '*.cshtml' and other Asp.Net files via WebDav on IIS 7.x

I have installed WebDav on Windows Server 2008 R2 Web Edition and the connection is working perfectly except when I try to download a protected Asp.Net file, like myfile.cshtml or web.config I get an Error downloading file! (404).

All the other files work fine.

I guess some ISAPI is blocking the access somehow. I found this article but it didn't solve my problem: http://www.webdavsystem.com/server/documentation/hosting_iis_asp_net/protected_folders

I removed the RequestFilteringModule, every aspnet_filter.dll, every entry for Request Filtering. I can see my App_Data folder. I can upload *.cshtml files and delete them. I can even overwrite them but I can't download them.

What am I missing?

like image 353
Michael A. Volz aka Flynn Avatar asked Nov 20 '25 09:11

Michael A. Volz aka Flynn


1 Answers

Here is an excerpt that does most of what you want (allowing .config, .cs, and ect.):

<?xml version="1.0"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <fileExtensions allowUnlisted="true">
          <clear />
        </fileExtensions>
        <hiddenSegments>
          <clear />
        </hiddenSegments>
      </requestFiltering>
    </security>
  </system.webServer>
  <system.web>
    <httpHandlers>
      <remove path="*" verb="GET" />
    </httpHandlers>
  </system.web>
</configuration>

I'm still working on the .cshtml bit...

EDIT: I have updated this with what is working for me.

like image 88
John Gietzen Avatar answered Nov 23 '25 01:11

John Gietzen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!