{"id":1434,"date":"2013-08-16T11:28:22","date_gmt":"2013-08-16T11:28:22","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2013\/08\/16\/install-mvc4-hottowel-spa-nugetnuget-package-in-one-asp-net-web-api-project-in-vs2013-preview\/"},"modified":"2022-08-09T06:05:26","modified_gmt":"2022-08-09T13:05:26","slug":"install-mvc4-hottowel-spa-nugetnuget-package-in-one-asp-net-web-api-project-in-vs2013-preview","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/install-mvc4-hottowel-spa-nugetnuget-package-in-one-asp-net-web-api-project-in-vs2013-preview\/","title":{"rendered":"Install MVC4 HotTowel SPA NuGetNuGet package in One ASP.NET Web API Project in VS2013 Preview"},"content":{"rendered":"<p>I was trying to install MVC4 <a href=\"http:\/\/www.asp.net\/single-page-application\/overview\/templates\/hottowel-template\">HotTowel SPA package<\/a> (MVC4 and Razor v2) on a VS2013 Preview One ASP.NET Web API Project (MVC5 and Razor V3). I blindly let the NuGetNuGet package overwrite all my files including the <i>Viewsweb.config<\/i> file, which caused some compatibility problems.<\/p>\n<p>This is what I did:<\/p>\n<p>1. Create a Web API One ASP.NET project<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/08\/3377.clip_image002_thumb_60654F38.jpg\"><img decoding=\"async\" title=\"clip_image002\" border=\"0\" alt=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/08\/3377.clip_image002_thumb_60654F38.jpg\" width=\"628\" height=\"391\" \/><\/a><\/p>\n<p>2. Manage NuGet packages, find HotTowel: ASP.NET MVC SPA Template package, click Install.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/08\/8270.clip_image004_thumb_747E6BC1.jpg\"><img decoding=\"async\" title=\"clip_image004\" border=\"0\" alt=\"clip_image004\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2013\/08\/8270.clip_image004_thumb_747E6BC1.jpg\" width=\"628\" height=\"420\" \/><\/a><\/p>\n<p>3. I chose \u201cYes to All\u201d when prompted for file overwriting. <strong>I should have chosen \u201cYes\u201d and \u201cNo\u201d buttons for each file overwriting warning dialog in order to prevent overwriting <i>Viewsweb.config<\/i>.<\/strong><\/p>\n<p>4. CTRL-F5 to run the application, I get the following error in IE:<\/p>\n<p><i>[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from &#8216;System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&#8217; in the context &#8216;Default&#8217; at location &#8216;C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.WebPages.Razorv4.0_2.0.0.0__31bf3856ad364e35System.Web.WebPages.Razor.dll&#8217;. Type B originates from &#8216;System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&#8217; in the context &#8216;Default&#8217; at location &#8216;C:UsersxinqiuAppDataLocalTempTemporary ASP.NET Filesroot3c4ae604700fa44cassemblydl38be5ce887c28f49b_e28fce01System.Web.WebPages.Razor.dll&#8217;.<\/i><\/p>\n<p>5. It took me quite a while to figure out what was wrong since the <i>~\/web.config<\/i> is correct, until I realized there is also a <i>Views\/web.config<\/i> file. After I manually corrected the <i>Views\/web.config<\/i> file to match a normal Web API project <i>Views\/web.config<\/i> file, the application works correctly with HotTowel features.<\/p>\n<p>Later I found this experience matches the following StackOverflow question about migrating an MVC4 project to MVC5: <a href=\"http:\/\/stackoverflow.com\/questions\/17454852\/upgrading-from-mvc4-to-mvc5-pre-release\">http:\/\/stackoverflow.com\/questions\/17454852\/upgrading-from-mvc4-to-mvc5-pre-release<\/a>. So hopefully my simple mistake might have some value to be shared.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was trying to install MVC4 HotTowel SPA package (MVC4 and Razor v2) on a VS2013 Preview One ASP.NET Web API Project (MVC5 and Razor V3). I blindly let the NuGetNuGet package overwrite all my files including the Viewsweb.config file, which caused some compatibility problems. This is what I did: 1. Create a Web API [&hellip;]<\/p>\n","protected":false},"author":410,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[7425,7436],"class_list":["post-1434","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","tag-spa","tag-visual-studio-2013"],"acf":[],"blog_post_summary":"<p>I was trying to install MVC4 HotTowel SPA package (MVC4 and Razor v2) on a VS2013 Preview One ASP.NET Web API Project (MVC5 and Razor V3). I blindly let the NuGetNuGet package overwrite all my files including the Viewsweb.config file, which caused some compatibility problems. This is what I did: 1. Create a Web API [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/410"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=1434"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1434\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=1434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=1434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=1434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}