views:

478

answers:

2

I've been following this guide from MSDN about "Creating an ASP.NET MVC Areas Application Using Multiple Projects". Since ASP.NET MVC 2.0 is just preview one would imagine there to be some bugs.

My problem is, it simply doesn't work! At least not the way it's suppose to. After setting everything up and pressing F5, one would think that, this will work, neat! BEEEP. Wrong.

It doesn't find the Views in the child project! Because in my case it tries to search within ~/Views which of course is in the parent!

When debugging i see that it Does run the Controller inside my child project, but when using return View(); on that Action, it looks inside the Parent View-folders.

I ask, Bug or Feature?

Tried this in both Vs2009, Vs2010 with both Framework 3.5 and 4.0.

A: 

I went through the same pain as you. This is what I did.

  1. Made sure I was running MVC 2 RC (uninstall beta 2, install the RC).
  2. Recreated the project from scratch.
  3. No need to edit the csproj files, no need to create a routes.cs, and no need to edit global.ascx.cs, just right click the main project to get the context menu. From the Add menu item you can create a new area.
  4. The views have to be in the main project or you can use the information in this post http://forums.asp.net/p/1494640/3540105.aspx, which I plan on doing so the views are in each area.

It doesn't support the Multi-Project areas, but for now that's ok with me. The link above does point you in the direction for multi-project areas.

37Stars
"It doesn't support the Multi-Project areas", well then it's not a solution to my problem, is it?
Filip Ekberg
I believe I said it wasn't a multi-project solution, but it is a solution to the problem. It may be one other people are interested in knowing, since multi-project areas support was removed in the release candidate.
37Stars
If you read my question again, you see that I already covered the part about you needing to have it in the main project.
Filip Ekberg
Wow, the accepted answer gives the same link I did.
37Stars
+1  A: 

I put "multi project areas" in Google and came accross this post: http://forums.asp.net/p/1494640/3540105.aspx. Note specifically Phil Haack's response.

It appears that defining your views in the parent project is "functioning as designed" because of this entry in the MSDN post: Now that all the code is in place, the final step is to customize the build process for each area project. This customization causes some child-area files, such as the views, to be copied to the main project before the application is built.

The "problem" with the post is that it was defined for the beta where this build step was easily accessable. RC+ you have to point to the Futures assembly and assign the build step slightly differently if this is the path you choose.

If you don't like the direction this pushes you, the portable areas portion of MvcContrib Phil mentions is about as good as you're gonna get to an alternative.

w0rd-driven
Thanks, that explains it.
Filip Ekberg