Monday, September 29, 2014

Deploy ASP.NET MVC to Linux

If you received this error when deploying Visual Studio ASP.NET MVC project to Linux/Unix Mono environment:

System.InvalidOperationException
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml


Chances are the Precompile during publishing option is checked when you published your project, just uncheck it then the error will go away:





Tested ASP.NET MVC 4


Note that if you are deploying ASP.NET MVC project instead of ASP.NET one, the fastcgi_index in configuration file "/etc/nginx/sites-available/default" have to be removed, otherwise you'll receive this error:





Update Oct 4, 2014


Upon further investigation. We can also leave the Precompile during publishing checked, but we must click Configure link, then uncheck the Allow precompiled site to be updatable




Happy Deploying!


No comments:

Post a Comment