views:

23

answers:

1

I just upgraded from VS2010 RC to RTM. Now my areas aren't working. I have a Profile area with a Home controller and an Action method Index().

If I try: http://localhost:4951/profile I get a 404 error saying that the resource can't be found. If I try http://localhost:4951/profile/home I get the same error. However, if I try http://localhost:4951/profile/home/index then the view is returned.

Here is my ProfileAreaRegistration:

public class ProfileAreaRegistration : AreaRegistration { public override string AreaName { get { return "Profile"; } }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Profile_Unlock",
            "Profile/Unlock/{userID}/{unlockID}",
            new { controller = "Unlock", action = "Index" },
            new { userID = new GuidRouteConstraint(), unlockID = new GuidRouteConstraint() }
        );

        context.MapRoute(
            "Profile_default",
            "Profile/{controller}/{action}/{id}",
            new { action = "Home", id = UrlParameter.Optional }
        );
    }

Does anyone know what is going wrong?

+1  A: 

Use the routing debugger to find out which route is being applied

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

Raj Kaimal
That did the trick! One more question though. I have a custom route constraint within another area that looks like this:context.MapRoute("Account_Users", "Account/Users/{action}/{pageNumber}/{pageSize}/{filter}/{orderBy}",new { area = "Account", controller = "Users", action = "List", pageNumber = 1, pageSize = 20, filter = "all", orderBy = "name" },new[] { "NS.Web.Areas.Account" });The route tester shows that it is the first route to match but I still get a 404 error. Any ideas as to what might be causing this?
devlife
Put a break point on the List method. Is it being hit?
Raj Kaimal
the List method never gets hit. However, I figured it out. I removed the namespace declaration in the route definition and it works. I'm not sure why that would make a difference but it works fine now.
devlife