views:

312

answers:

1

I have just installed the RTW 1.0 of the MVC framework. I was using RC2 in the past to go through the tutorials. I now have a problem where basic routing doesn't work which i didn't have in RC2.

If i create a new MVC application in VS 2008 the routings for the home page don't work out of the box.

The following URL's work for some reason

http://mydomain/
http://mydomain/Home/Index/1

However the following don't work and give 404 errors.

http://mydomain/Home
http://mydomain/Home/Index

My RegisterRoutes method is the default and looks like this

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

        }

My HomeController.cs looks like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyNamespace.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }
    }
}

and the index view is just the default that is generated

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%= Html.Encode(ViewData["Message"]) %></h2>
    <p>
        To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc&lt;/a&gt;.
    </p>
</asp:Content>
A: 

I have managed to track down the problem. I was hosting it in IIS 7 on an old website project. There must have been some funky settings (It was set to integrated mode though). So all i did was create a new website and app pool and it worked first go :) Took me hours though!!!

Alex