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 By: Anonymous
Worked for me
Thank you very much, saved my nerves :)
Posted By: Anonymous
Thanks
This worked for me
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 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 By: Anonymous
Thanks
Thanks it saved a lot of time.
Again Thanks dude.
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 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 By: Anonymous
Solved my problem
This was the exact solution I was looking for
Thanks
Posted By: Anonymous
thanks for info
thanks for the infor this helped me to salve the same problem with razor
Post new comment