C# and Razor - The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect

后端 未结 6 1151
别跟我提以往
别跟我提以往 2021-01-02 01:09

I have looked through other posts but none seem to answer what I need.

  • I created an empty site in WebMatrix (ASP.NET)
  • I opened that site in VWD 2013
6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 02:04

    In my case the culprit was the fact that Global.asax was placed under the '/Views' folder. This was somehow working while the project was targeting MVC3. Once the solution got upgraded to MVC4, running said solution would result in the aforementioned errors. In a similar vein, other errors would crop up mentioning:

    "no default webpage has been set and directory browsing has been disabled"

    The solution: After upgrading to MVC4+ I had to manually move Global.asax under the root folder of the container project. Be sure to inspect Global.asax to make sure that the namespace applied within is the proper one. Just my 2c.

提交回复
热议问题