Asp.net mvc 2 preview 2 and Spark

Has some body tried Spark View Engine with asp.net mvc 2 preview 2?

I have a problem with AREAS .

The spark engine seems to look **. Sparks * files inside the View folders instead of the Regions folder are optional.

My question is:

Someone has information on how to add it?

+3
source share
2 answers

Spark will not automatically check the location of views in the current version. If you want to change the source (which I assume you if you are doing mvc 2), here is the fix:

src\Spark.Web.Mvc2\Descriptors\AreaDescriptorFilter.cs, ( **):

: , , MIGHT .

, , .

, , .

  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;
    }
}
+2

Spark "area" . MVC 2 , :

public class AdminRoutes : AreaRegistration
{
    public override string AreaName
    {
        get { return "admin"; }
    }

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "admin_default",
            "Admin/{controller}/{action}/{id}",
            new { controller = "Dashboard", action = "Index", id = "", area = "admin" },
            new [] { "MyProject.Areas.Admin.Controllers" });
    }
}

area = "admin" .

+1

Source: https://habr.com/ru/post/1720481/


All Articles