Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 641
Vnuk Avatar asked Jan 28 '10 22:01

Vnuk


1 Answers

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.

like image 176
Vnuk Avatar answered Nov 17 '22 10:11

Vnuk