Why I can not publish the MVC project

I'm having trouble publishing my MVC project. When I publish and upload everything to a web server, I get the following:

[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] 

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

My routing code is:

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

I use IIS7 on a Windows 2008 web server. ASP.NET MVC 1.0, Visual Studio 2008. I tried it locally with IIS7 on Windows 7 - same error.

UPDATE I created a new MVC project and added all my files to it. Link to projects is referred to as compiled binaries. After publishing "only the files needed to run the application", I get the same error.

+7
asp.net-mvc publish
source share
8 answers

The solution to this problem is as strange as its manifestation.

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

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

and it was supposed to be

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

Why is something acceptable for Cassini, and not for IIS, is not in my power to understand. I just hope this answer saves someone else from my headache.

+1
source share

Check if the index.aspx master page also exists.
If you are using the website project, try selecting the option "Allow this pre-compiled site to update" when publishing the site.
If you are using a web application project, try selecting the option “Copy all project files” in the publication.

Try also copying only those species. I think ASP.NET MVC projects when precompiled do not work due to marker files (.aspx and ascx files are replaced by marker files during precompilation).

If you are using IIS 6 or lower, check out the asp.net mvc deployment guide - http://www.asp.net/learn/mvc/tutorial-08-cs.aspx .

0
source share

1) Check if your Index.aspx is included in the project. (exists in the publication results folder) Locally in VS, it can work, but it will not be copied during publication.

2) Check if the Views / web.config file is included in the project - it affects ASP.NET MVC by compiling the views.

3) Check if Index.aspx Build Action = Content (in the properties window).

0
source share

Check the rights on the server, make sure that the asp.net workflow has the correct rights in the folders, subfolders and view files.

Also, does your IIS instance run in Classic or Integrated Pipeline mode?

0
source share

Removed previous link, this explains it a little better http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis7/ .

If you are developing a local asp.net web server, you should remove some of the HttpHandlers and HttpModules, and then add them back to the section. This suggests that IIS7 runs them in integrated mode. This is necessary when deploying your application to IIS 7, including MVC. See below for a reference example:

 <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true"> <remove name="ScriptModule" /> <remove name="UrlRoutingModule" /> <add name="FormsAuthenticationModule" type="System.Web.Security.FormsAuthenticationModule" /> <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </modules> <handlers> <remove name="WebServiceHandlerFactory-Integrated" /> <remove name="ScriptHandlerFactory" /> <remove name="ScriptHandlerFactoryAppServices" /> <remove name="ScriptResource" /> <remove name="MvcHttpHandler" /> <remove name="UrlRoutingHandler" /> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </handlers> </system.webServer> 

Hope this helps,

Eddy

PS. Old link http://www.asp.net/(S(ywiyuluxr3qb2dfva1z5lgeg))/learn/mvc/tutorial-08-cs.aspx

0
source share

What is the exact call to the View ("Index", ...) that you are using. Perhaps the second parameter is the string — in this case, another overload of the View method is used, where the second parameter is the name of the main page.

Solution: just enter the second parameter as an object.

0
source share

Since it works when copying an entire project, maybe you are not copying all the files you need? Make sure that any non-standard links are set to Copy local and use the built-in Publish function in the Build menu to get the files you need to run the project.

0
source share

Try adding .aspx to the URL controller part, for example, http: //myserver/appname/Index.aspx/Home - if I remember correctly, IIS7 has problems with MVC applications that display the correct links / actions, a) refer to the controller part, using the suffix .aspx b) configure the settings on the server, but it affects all applications on this server c) download the addon I found a good article about this, but I can’t find it, search around, and I'm sure you will find it yourself if the .aspx solution is not suitable for you.

-one
source share

All Articles