Search code examples
asp.net-mvcpublish

Why can't I publish MVC project


I'm having problems publishing my MVC project. When I do publish and upload everything to web server I get this:

[InvalidOperationException: The view 'Index' or its master could not be found. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx]

Weird thing is that Index.aspx exists in ~/Views/Home/, but IIS cannot find it there. If I copy entire project to web server and let asp.net compile it on the fly it works like a charm.

My routing code:

  routes.MapRoute( _
    "Default", _
    "{controller}/{action}/{id}", _
    New With {.controller = "Home", .action = "Index", .id = ""} _
  )

  routes.MapRoute("Root", "", New With {.controller = "Home", .action = "Index", .id =""})

I'm using IIS7 on Windows 2008 Web server. ASP.NET MVC 1.0, Visual Studio 2008. I've tried it local with IIS7 on Windows 7 - same error.

UPDATE - I've created a new MVC project, and added all my files to it. Referencing projects have been referenced as compiled binaries. After publishing "only files needed to run application" I get the same error.


Solution

  • Solution to this problem is as bizarre as it's manifestation.

    My master code behind file was declared as Partial instead of Public and my master definition was

    <%@ Master Language="VB" Inherits="SiteFrontPageMaster"  ClassName="SiteFrontPageMaster" CodeFile="SiteFrontPageMaster.Master.vb"  %>
    

    and it should have been

    <%@ Master Language="VB" Inherits="mymvcproject.SiteFrontPageMaster" CodeBehind="SiteFrontPageMaster.Master.vb" %>
    

    Why was something acceptable for Cassini and not for IIS is beyond my ability to understand. I just hope that this answer saves someone else my amount of headache.