Bashar Abu Shamaa
Bashar Abu Shamaa

Reputation: 2029

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!

Upvotes: 5

Views: 980

Answers (1)

scartag
scartag

Reputation: 17680

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.

Upvotes: 3

Related Questions