Note that there are some explanatory texts on larger screens.

plurals
  1. POIIS returns 404 for ASP.NET MVC3 file (.cshtml)
    primarykey
    data
    text
    <p>I have standard ASP.NET 4 application. Inside this application there are also few razor (e.g. <code>test.cshtml</code>) files. ASP.NET application works however if I point browser to <code>/test</code> file (without extension). IIS (static file handler) returns 404.</p> <p>The same application and even the standalone <code>.cshtml</code> files are working on local machine (with IIS7.5/Win7) and a server with (IIS7.5/Win2008R2), however it does not work the server with IIS7.0/Win2008.</p> <p>MVC3 is installed on both machines, app pools on both machines are .NET 4.0 integrated.</p> <p><strong>How the <code>.cshtml</code> handlers works? When the IIS decides to use static file handler and when the <code>.cshtml</code> handler? What else should I check?</strong></p> <p><em><strong>EDIT:</em></strong> </p> <p>Clarification - I am not actually using whole MVC framework, it is just like plain-old .ASPX or PHP file. No controllers, no routes, no 'views'. I am using it for a simple script in addition to old ASP.NET application.</p> <p>I think it is not a programming issue, since it works on local computer, but rather a configuration issue - the IIS on the Win2008 server might not be configured properly.</p> <p><em><strong>EDIT2:</em></strong></p> <p>(Machines with IIS7.5 works, only machine with IIS7.0 does not work. But I am not sure whether it is a problem of IIS version.)</p> <p><em><strong>EDIT3:</em></strong></p> <p>On my local computer where it works, I have not set any routing. TheCodeKing and Keith suggested that I need to have a routing somewhere. Maybe yes, but it is not in my application. It might be set by default somewhere in IIS configuration.</p> <p><strong>Do you have any hints where this 'implicit' routing could be found?</strong></p> <p><em><strong>EDIT4:</em></strong></p> <p>Note: On all computers there is <code>HttpForbiddenHandler</code> for <code>*.cshtml</code>, since you cannot download the cshtml file. And there is also the <code>TransferRequestHandler</code> for <code>*.</code>. (Both are enabled.)</p> <p><em><strong>EDIT5:</em></strong></p> <p>I have found that on the servers, where it is working, I need to have any <code>.cshtml</code> file in the web root. If I remove the <code>.cshtml</code> from the web root and try to invoke any from a subdirectory it will not work.</p> <p><em><strong>EDIT6:</em></strong></p> <p>I tried that on another two machines: one with <code>IIS 7.5</code> and another with <code>IIS 7.0</code>. On <code>IIS 7.5</code> it works (plain install no configuration), but on <code>IIS 7.0</code> it does not work.</p> <p><strong>How to make it work on IIS 7.0?</strong> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload