===
I've tried use Areas future of MVC 2 in my web.But when I changed the
view engine to Spark, the Areas could not work. It thrown some
problems like 'can not find resources'.
===
My web application with Areas:Samples, Controller: Home, Action:Index.
Here is some codes below.
Code of Controller:
namespace Web.Areas.Samples.Controllers
{
public class HomeController : Controller
{
public ActionResult Index() {return View();}
}
}
Code of AreaRegistion :
namespace Web.Areas.Samples
{
public class SamplesAreaRegistration : AreaRegistration
{
public override string AreaName {get { return "Samples"; }}
public override void RegisterArea(AreaRegistrationContext
context)
{
context.MapRoute(
"Samples_default",
"Samples/{controller}/{action}/{id}",
new { Area = "Core",action = "Index", id =
UrlParameter.Optional }
//new { controller = "Home", action = "Index", id =
"", area = "Core" } //I have tried to add 'area' to route key, but it
seems not take any effect.
);
}
}
}
Code global.asax.cs:
protected void Application_Start()
{
SparkEngineStarter.RegisterViewEngine(ViewEngines.Engines);
AreaRegistration.RegisterAllAreas();
routes.Add(new Route("{controller}/{action}/{id}", new
MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { action =
"Index", id = "" }),
});
}
The location of View file in web :
~/Areas/Samples/Views/Home/Index.spark
===
I did some failure tests:
1. To visite another URL for Controller:Home, Action:Index ,like /Home/
Index, is good. The View is located at "~/Views/Home/Index.spark".
2. I had tried to change the source code
PotentialViewLocations.DefaultDescriptorBuilder flowing this article
and recompiled, but is also can not work.
http://www.silverxu.com/making-spark-view-engine-to-work-with-asp-net-mvc-2-areas/
3. there is an AreaDescriptorFilter in source code. And the instance
is added in SparkEngineStarter.CreateContainer struct. I tried these
code below in Application_Start, and it didn't work either:
var services = SparkEngineStarter.CreateContainer();
services.AddFilter(new AreaDescriptorFilter()); //AddFilter or not ,
both have tried.
SparkEngineStarter.RegisterViewEngine(engines, services);
===
Is there some steps i missed? Or some other method can resolve it?
Thanks for any suggestion.