简体   繁体   中英

web.config file not there in the root(/) directory

I was trying to run a .cshtml file but it gave an error:

Server Error in '/' Application.
--------------------------------------------------------------------------------


This type of page is not served. 
  Description: The type of page you have requested is not served because it has been explicitly forbidden.  The extension '.cshtml' may be incorrect.   Please review the URL below and make sure that it is spelled correctly. 

 Requested URL: /index.cshtml

So I searched for the solution and found that I had to edit the web.config file which is in the root directory(here it is My Site), but there is no file like that there there is only an index.cshtml which I had created.

I searched even the IIS and the IIS Express folders in Programs Files\\ but there was no file like that?

If you are using WebMatrix, maybe your mistake was the starting point choice.

If you want to create a new Web Pages site you must start from a template in the Template Gallery of WebMatrix. Pay attention that the Empty Site template differs from the Empty Site option outside the Template Gallery because the first holds the files (binaries, packages and the web.config too) that are needed.

As the server error suggests, .cshtml files are not served, the reason for this is because they are server-side files that make up your application, they are just one piece of a much bigger picture.

If you launched your web application in debug mode and the URL in the browser was something like http://localhost:2932/Views/Home/Index.cshtml , just drop the /Views/Home/Index.cshtml part of the URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM