what is the function of webpages:Enabled in MVC 3 web.config

asp.net Mvc-3

asp.net Mvc-3 Problem Overview


I just started a new MVC 3 project. Can anyone tell me what

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

in my web.config file does?

asp.net Mvc-3 Solutions


Solution 1 - asp.net Mvc-3

webPages:enabled with value false prevents .cshtml or .vbhtml files in the Views folder from being directly accessible from a web browser.

Solution 2 - asp.net Mvc-3

According to documentation it prevents .cshtml and .vbhtml files from being accessed directly (www.myweb.com/views/home/index.cshtml for example)

Solution 3 - asp.net Mvc-3

To allow Razor pages to be served, it's not enough to set <add key="webpages:Enabled" value="true" />. You also need to add the Microsoft.AspNet.WebPages package to packages.config using NuGet.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionftnilssonView Question on Stackoverflow
Solution 1 - asp.net Mvc-3Neil KnightView Answer on Stackoverflow
Solution 2 - asp.net Mvc-3Lukáš NovotnýView Answer on Stackoverflow
Solution 3 - asp.net Mvc-3Ron InbarView Answer on Stackoverflow