asp.net mvc的2 preVIEW 2和星火 [英] asp.net mvc 2 preview 2 and Spark

查看:195
本文介绍了asp.net mvc的2 preVIEW 2和星火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些身体试图星火视图引擎与asp.net MVC 2 preVIEW 2 的?

我有一个问题

它看起来喜欢火花引擎看起来*的 .spark 的意见的文件里面在另外文件夹文件夹区域只来代替。

It looks likes spark engine looks *.spark files inside of Views folders only instead of Areas folder in additionally.

我的问题是:

有人有资料怎么加呢?

推荐答案

星火不会自动检查区域在当前版本中查看的位置。如果你愿意改变源(我假设你是如果你正在做MVC 2的东西),这里的修复:

Spark will not automatically check the area views location in the current version. If you're willing to change the source (which i assume you are if you're doing mvc 2 stuff), here's the fix:

您必须修改文件的的src \\ Spark.Web.Mvc2 \\叙\\ AreaDescriptorFilter.cs ,以便它读取如下(按**突出的变化):

You have to modify the file src\Spark.Web.Mvc2\Descriptors\AreaDescriptorFilter.cs so that it reads as below (changes highlighted by **):

注意:我没有机器,我跟我这样做,所以在格式字符串中的斜线可能需要斜杠

Note: I don't have the machine i did this on with me, so the slashes in the format string MIGHT need to be forward slashes.

另外,也可以在自己的code创建这个类,并通过它,当你注册视图引擎,但我​​不记得configuraiton code从我的头顶。

Also, it is possible to create this class in your own code and pass it in when you register the view engine, but I don't remember the configuraiton code off the top of my head.

这是因为我想修改尽可能少的火花源我做的方法。

That's the approach I did since I wanted to modify the spark source as little as possible.

  public class AreaDescriptorFilter : DescriptorFilterBase
{
    **private const string areaPathFormatString = "~\\Areas\\{0}\\Views";**
    public override void ExtraParameters(ControllerContext context, IDictionary<string, object> extra)
    {
        object value;
        if (context.RouteData.Values.TryGetValue("area", out value))
            extra["area"] = value;
    }

    public override IEnumerable<string> PotentialLocations(IEnumerable<string> locations, IDictionary<string, object> extra)
    {
        string areaName;

        return TryGetString(extra, "area", out areaName)
                   **? locations.Select(x => Path.Combine(string.Format(areaPathFormatString,areaName), x)).Concat(locations)**
                   : locations;
    }
}

这篇关于asp.net mvc的2 preVIEW 2和星火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆