views:

139

answers:

3

Hi, I need help. I can't access my portable area from my main project. I build everything and I get a 404 error when trying to access this portable area (localhost:123/IW/Home), but all my regular areas are working fine (ex: localhost:123/Portal/Home)

Here's what I did in order to install my portable area -I downloaded MVCContrib -I added reference to MVCContrib.dll in my main project (called WAB)

-I created a new Class Librairy project in the same solution as WAB. -This new Class Librairy is called IWPortableArea and I added the necessary assemblies references (MVCContrib, System.mvc, ...)

-I created a IWRegistration:

namespace IWPortableArea
{
    public class IWRegistration : PortableAreaRegistration
    {
        public override void RegisterArea(System.Web.Mvc.AreaRegistrationContext context, IApplicationBus bus)
        {
            context.MapRoute(
                "iw",
                "iw/{controller}.aspx/{action}",
                new { controller = "login", action = "index" });

            RegisterAllAreas(GetType());
        }

        public override string AreaName
        {
            get { return "iw"; }
        }


    }
}

-I created a simple controller that's not making use of any view file:

namespace IWPortableArea.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return Content("yo you are in IW Portable Area, congrats");
        }
    }
}

-I added a reference in my main project to the portable area: IWPortableArea.dll

-Finally I modified the Global.asax.cs of my main application to:

public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


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

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
A: 

I have the same problem. Can't get this to work.

Have followed this example: http://www.lostechies.com/blogs/hex/archive/2009/11/02/asp-net-mvc-portable-areas-part-2.aspx

Notice: "An important caveat around the setup of the Registration class is to make sure that the Registration class is sitting in the same Namespace as the controllers and views"

ingljo
A: 

Remember to create a folder with the name "Areas" in the hosting application. This solved my problem.

ingljo
A: 

Did you change the compile action of the area view to Embedded Resource?

Michael Shimmins