views:

83

answers:

1

We recently upgraded a project to MVC 2 and we'd like to use Areas but there is an issue.

We have created a new area, setup a controller, configured a route, and created a view in the correct location. When we run the code it successfully finds the route and hits the controller but when it goes to render the view there is an exception.

The web forms view engine doesn't seem to be looking in the Areas section for views. The error we're seeing is:

~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx

When it should be:

~/<AreaName>/Views/<ControllerName>/<ViewName>.aspx
~/<AreaName>/Views/<ControllerName>/<ViewName>.ascx
~/<AreaName>/Views/Shared/<ViewName>.aspx
~/<AreaName>/Views/Shared/<ViewName>.ascx
~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx

This would indicate that it's still somehow using the MVC 1 dll but we've looked carefully and can find only references to the V2 of MVC (there was a V1 reference in xVal, a third party DLL, but fixing that didn't make a difference).

I can only imagine that we missed something when we did the upgrade or that we've got some unusual edge case because there doesn't seem to be anything on the web that matches the problem we're experiencing.

What things could we look at that might help us resolve this issue?

Thanks in advance for any help provided. Cheers, Zac

+1  A: 

What things could we look at that might help us resolve this issue?

  1. Make sure Area Routes are Registered AreaRegistration.RegisterAllAreas(); are registered first. Area routes need to be registered as well.
  2. Make sure generated URL links have the area name included as one of the arguments when using ActionLink and other related URL helpers
  3. Sometimes just delete and re-add the Area from scratch. Sounds silly, but it works.
  4. The related SO question on the left hand side of this page may help. I have linked one I think may be of value
Ahmad
Thanks for the response Ahmad, unfortunately, none of these have helped. As I mentioned in a comment on the question, above, the problem is not related to routes - it's an issue with the WebFormViewModel as far as I can tell. We've reproduced the issue with a couple of computers/devs so adding and then removing areas hasn't helped.
Zac
@zak - what's a WebFormViewModel?
Ahmad