2

I am working on an MVC project in Visual Studio 2010 with .NET Framework 4.0 + MVC2 and everything works if I set the target framework to .NET 4.0. However, my host does not offer .NET 4.0 in order to deploy the site I need to get it working on .NET 3.5.

I tried converting it to ASP.NET 3.5 and everything builds just fine except now when I try to load the homepage, I get a 404 Error saying:

The resource cannot be found.

 Description: HTTP 404. The resource you are looking for (or one of its dependencies)      could have been removed, had its name changed, or is temporarily unavailable.  Please      review the following URL and make sure that it is spelled correctly. 

 Requested URL: /home

 Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET  
 Version:2.0.50727.4927

Anyone know why this is?

Thank You for Your help. TheLorax

2

3 Answers 3

1

From my experience with ASP.NET MVC, I've seen that a Default.aspx page is required for IIS to function correctly. I'm using the page that was included in the ASP.NET MVC 1 template. Unfortunately, the ASP.NET MVC 2 does not include this page (to the best of my knowledge), so you should add the following to your project:

Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="YourNamespace._Default" %>

<%-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --%>

Default.aspx.cs:

using System.Web;
using System.Web.Mvc;
using System.Web.UI;

namespace YourNamespace
{
    public partial class _Default : Page
    {
        public void Page_Load(object sender, System.EventArgs e)
        {
            // Change the current path so that the Routing handler can correctly interpret
            // the request, then restore the original path so that the OutputCache module
            // can correctly process the response (if caching is enabled).

            string originalPath = Request.Path;
            HttpContext.Current.RewritePath(Request.ApplicationPath, false);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(HttpContext.Current);
            HttpContext.Current.RewritePath(originalPath, false);
        }
    }
}
0

Simple solution: switch to Visual Studio 2008 + SP1 + MVC 1. This is the released/supported combination. If your host doesn't install the MVC assemblies then they can be deployed side by side, you will need to ensure your host has .NET 3.5 SP1.

If I recall correctly VS2010 B2 includes MVC***2*** B2, but not MVC***1***.

0

It may be that the MVC assemblies are not installed on the server you are publishing to. Try going into your MVC project, then under resources and change the property copy local to true for all MVC specific assemblies (or just highlight everything under references and set this property to true).

You must log in to answer this question.