HomeBlogsgstevens's blogError - The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode

Error - The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode

If you've recently explored adding a razor page to an existing ASP.NET site, you may begin to get a cryptic error as follows:

The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an exception with the following error message: Exception has been thrown by the target of an invocation.

The core issue is that when you add a razor page, a new appSettings key is added to web.config. To fix this error, remove this from your web.config:

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

As soon as this is removed, your ASP.NET site/app should compile once again.


Comments

Posted On: December 11, 2013
Posted By: Anonymous

Worked for me

Thank you very much, saved my nerves :)

Posted On: June 18, 2013
Posted By: Anonymous

Thanks

This worked for me

Posted On: March 27, 2013
Posted By: Anonymous

Thanks. Hope I saw this earlier

Thanks. I could have saved a bunch of hours had I read your article earlier. I am sharing this with my team.

Posted On: January 28, 2013
Posted By: Anonymous

tanks

If your web config does not contain this key just add the key like that:
add key="webpages:Enabled" value="false"

Posted On: August 9, 2012
Posted By: Anonymous

Thanks

Thanks it saved a lot of time.
Again Thanks dude.

Posted On: June 22, 2012
Posted By: Anonymous

Not in file and still get the error

The web.config file does not contain and yet i'm still getting this error, any thoughts?

Posted On: August 6, 2012
Posted By: Anonymous

Not any any web.config?

Are you looking in all of the web.config files? It could be buried in web.config.Debug or web.config.Release.

Posted On: April 11, 2012
Posted By: Anonymous

Solved my problem

This was the exact solution I was looking for
Thanks

Posted On: July 11, 2011
Posted By: Anonymous

thanks for info

thanks for the infor this helped me to salve the same problem with razor


Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.