Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying Asp.Net MVC 2 /C# 4.0 application on IIS 6

I got a problem migrating from VS.Net 2008 / MVC 1 to VS.NET 2010 (+C# 4.0) / MVC 2

The web.config has been updated, the site runs well in Cassini, but my problem now is deploying on IIS 6.

I updated the web site to run using ASP.Net 4, but whatever URL I try, I always have a 404 error. It's as if the routing was not taken into account (yes, the wildcard mapping has been done).

I do not understand this mess and could not google anything interesting... Thanks for your suggestions !

like image 403
Mose Avatar asked Feb 23 '10 15:02

Mose


People also ask

How install MVC on IIS?

- Open 'Turn Windows features on or off' [Windows key then type 'Turn Windows features on or off' and open] - Scroll down the list and expand 'Internet Information Services' - Within that expand 'World Wide Web Services' - Within that expand 'Application Development Features' - Make sure 'ASP.NET 4.6' (or 3.5 if you ...

Can you mix Blazor and MVC?

Blazor applications are component-based. Blazor components can be used in existing ASP.NET MVC applications.


2 Answers

Ok I got y answer (thanks to a colleague)

When migrating from ASP.Net 2.0 to ASP.Net4.0, if you meet the same problem, then check in Web Service Extension if ASP.Net v4 is Allowed.

In my case, after installing the .Net framework 4, it was prohibited.

Will & Mark : thanks for your help, hope it will helps others.

like image 58
Mose Avatar answered Sep 25 '22 02:09

Mose


I think I know what's happening: on IIS6, as well as the wildcard mapping you will need a default document (Default.aspx) that routes folder requests to the MVC handler.

There was one included with the MVC1 project templates, but it has been removed in MVC2.

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. --%>

and 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);
        }
    }
}

When you say "It's as if the routing was not taken into account", I suspect that it actually isn't, and this is your problem.

like image 31
Mark Bell Avatar answered Sep 24 '22 02:09

Mark Bell