Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wierd viewlocations when in the scope of a Area #21

Closed
Danthar opened this issue Aug 17, 2011 · 1 comment
Closed

Wierd viewlocations when in the scope of a Area #21

Danthar opened this issue Aug 17, 2011 · 1 comment
Labels

Comments

@Danthar
Copy link

Danthar commented Aug 17, 2011

I ran into this issue purely by happenstance. When resolving a view inside the context of an area i am getting the following view locations returned.

(excerpt from the complete listing, showing only the relevant entry's
where Account is the area)

  • Account~\Areas\Account\Views\MyController\Index.spark
  • Account~\Areas\Account\Views\Shared\Index.spark

As you can tell these locations will never yield any correct path. I started digging and found out what the problem was.

In the DefaultDescriptorBuilder the PotentialViewLocations adds the Area's path with the ~ in front.(see: https://github.com/SparkViewEngine/spark/blob/master/src/Spark.Web.Mvc/DefaultDescriptorBuilder.cs#L198) I understand why it does this. However it fails to take the AreaDescriptorFilter into consideration. Causing the locations to show up as they do.

The changes made in the DefaultDescriptorBuilder are to have spark support the Area viewlocations that are default in the MVC framework. Where as the AreaDescriptorFilter is basically legacy code left in to provide backwards compatibility for people who have their views in the old locations. However it cannot be discarded completely because its needed to set the Area key in the extra dictionary used in PotentialViewLocations.

Not sure what the right solution to this problem would be though. However i do have a suggestion. The current way in which the new locations are added feels like a hack, considering Spark has DescriptorFilters to modify the ViewLocations collection.
A solution could be to provide the controller and viewname to the DescriptorFilter(s) as well, basically allowing them to properly build a viewlocation themselves and add that to the collections. This way the AreaDescriptorFilter can be responsible for adding the new ~{0}Areas{0}{1}{0}Views{0}{2}{0}{3}.spark style location in the proper way.

@RobertTheGrey
Copy link
Member

Fixed in v1.6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants