Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Ignore route for a specific View folder or a sepecific cshtml file in ASP.NET MVC 4

I want to ignore the routing when browse a specific page in the Views folder, I unsuccessfully attempted that by use :

        routes.RouteExistingFiles = false;
    routes.IgnoreRoute("Views/NoMove/specificPage.cshtml");

But above didn't work, because the Internet browser ask me to download the file and it doesn't open/process it the page!

What is the problem please, and How to fix it!

like image 708
Bashar Abu Shamaa Avatar asked Oct 22 '22 01:10

Bashar Abu Shamaa


1 Answers

You'll need to add an entry in your web.config.

Check the appSettings section

add this (or update)

<add key="webpages:Enabled" value="true" />

The entry is probably there already, so just update the value from false to true.

They are 2 web.config files though .. one in the root of your app and another in the views folder .. you may need to add/update the entry on both.

The default value (false) prevents *.cshtml and *.vbhtml files from being accessed directly from the browser.

like image 120
scartag Avatar answered Dec 18 '22 22:12

scartag