Coding is fun till you get bit by a bug after which it starts making fun of you. The situation worsens when the error is coming from some other place. And today it happened with me. Got the following error just when I thought everything was correctly done and let’s run the project.


Parser Error Unrecognized configuration section system.web.webPages.razor Error

Weirdo! Some of these errors are really the doomsday of the savior. Having pulled half of my hair (not literally :P) I was really running out of time for something which was needed to be setup quickly.

What’s the solution?

The problem is caused because the razor section that the error is referring to is not identified by the Razor Engine. That’s because:

  1. Either you added the razor section to a wrong web.config file (remember there is a web.config file for your project and other one for views folder)
  2. You forgot to add some important lines to your web.config which could tell the razor engine to do the honors.

I tried too many things when I finally found a solution. Just add the following lines of code to the configSections tag of your web.config file and things should be OK in no time.

Hope the little snippet helps.