开发者

Areas over multiple projects - Views not found in child projects

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开发者_Go百科 both Framework 3.5 and 4.0.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜