Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » .cshtml files added under

.cshtml files added under

Jan Sangill
Reply

Hi,

I had some simple .cshtml files added under system, in which I called to run some scheduled tasks.

They were rendered in 8.X, and in 9.1.3. Now they are not rendered. When I goto the file, it just writes out all the code on the screen, as if its not recognized.

Why is this happening now:S

 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Jan

That is because of a change in web.config to ensure client side uploaded files cannot be executed.

You can modify web.config to make it go away - remove the entire section with stuff like this:

 <remove fileExtension=".cshtml" />
        <mimeMap fileExtension=".cshtml" mimeType="text/plain" />

BR Nicolai

Votes for this answer: 1
 
Jan Sangill
Reply

Ahh security.
I removed this now, and it goes to the 404 page now.

Another thing I need to fix?

 
Nicolai Pedersen
Reply

Hi Jan

Depends. In the forums her i.e., you can upload from the frontend. I.e. a cshtml file - making a security issue. So, that is why It should be thought through when editing the web.config.

You also simply move the files to i.e. /CustomModules/ or another subfolder in the root, or add another section that have another location path attribute set Files/MyCustomRazor and allow Razor only in that subfolder.

 <location path="Files" allowOverride="false">
    <system.webServer>
      <staticContent>
        <remove fileExtension=".cshtml" />
        <mimeMap fileExtension=".cshtml" mimeType="text/plain" />
        
        <remove fileExtension=".vbhtml" />
        <mimeMap fileExtension=".vbhtml" mimeType="text/plain" />

        <remove fileExtension=".aspx" />
        <mimeMap fileExtension=".aspx" mimeType="text/plain" />
      </staticContent>
      <handlers>
        <clear />
        <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
      </handlers>      
    </system.webServer>

 

You must be logged in to post in the forum