I updated my MVC Views from Webforms to Razor.
What I did is that I rewrite manually all the code in Razor and excluded the aspx from the project. So far so good.
Now something strange is happening when I run the web site. I still get the Webforms views even if I excluded them from the project and replaced them with Razor views.
I did add this to my Web config file :
<configSections>
<sectionGroup name="system.web.webPages.razor"
type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup,
System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35">
<section name="host"
type="System.Web.WebPages.Razor.Configuration.HostSection,
System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages"
type="System.Web.WebPages.Razor.Configuration.RazorPagesSection,
System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup> </configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory,
System.Web.Mvc, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages> </system.web.webPages.razor>
I added this block to my Web config from the views folder.
I also added a _ViewStart.cshtml
I don’t think IIS pays any attention to
.csprojfiles. So if your.aspxfiles are still in the directory, it will find them, and.aspxhas precedence over.cshtmlfiles. You’ll have to delete them or move them. (Or write your own ViewEngine, but I doubt that’s worth it for this.)