what is the function of webpages:Enabled in MVC 3

2020-01-26 05:56发布

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?

3条回答
我只想做你的唯一
2楼-- · 2020-01-26 06:08

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.

查看更多
冷血范
3楼-- · 2020-01-26 06:25

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

查看更多
乱世女痞
4楼-- · 2020-01-26 06:26

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

查看更多
登录 后发表回答