Reputation: 914
How to use one unique _viewstart.cshtml to all views and areas/views? I already move my _viewstart to root of the my site, but when I did this happened this error "Unable to cast object of type 'ASP._ViewStart_vbhtml' to type 'System.Web.WebPages.StartPage'.". My .configs are be inside /views folder. What's the problem?
Upvotes: 2
Views: 933
Reputation: 22329
How to use one unique _viewstart.cshtml to all views and areas/views?
Not sure if you mean by that 1 file for all or 1 file per area.
If you want to use simply a single _ViewStart file, it must be placed in the Views folder. That is where it is when starting a new MVC3 project.
If you want a file per area please read this post here:
How do I specify different Layouts in the ASP.NET MVC 3 razor ViewStart file?
"Unable to cast object of type 'ASP._ViewStart_vbhtml' to type 'System.Web.WebPages.StartPage'."
This looks like you are mixing Razor with Webforms. If you are using a mixture of view engines, check your Global.asax that both view engines are added.
protected void Application_Start()
{
...
ViewEngines.Engines.Add(new WebFormViewEngine());
ViewEngines.Engines.Add(new RazorViewEngine());
...
}
Try placing your _ViewStart file into the Views folder to start with as that is where it should be.
Upvotes: 1
Reputation: 4379
For a file to be shared it shouldn't be in the root folder of the site. It should be in the Views/Shared folder.
Upvotes: 0
Reputation: 93424
I'm pretty sure you can't put the _ViewStart in the root of your site. The ViewEngine looks for ViewStart in the Views folder. So the only way to share the same ViewStart would be to use a hardlink and make the same file appear in both folders.
Upvotes: 0