I'm trying to render a plain html view using Spark and MVC but I obtain the following error:
The view 'Principal.html' or its master could not be found. The following locations were searched:
~/Views/Site/Principal.html.aspx
~/Views/Site/Principal.html.ascx
~/Views/Shared/Principal.html.aspx
~/Views/Shared/Principal.html.ascx
Site\Principal.html.spark
Shared\Principal.html.spark
In my controller i have:
public ViewResult Principal()
{
return View("Principal.html");
}
I register the spark engina in my Global.asax, Start method
protected override void Start()
{
...
RegisterViewEngine(ViewEngines.Engines, RouteTable.Routes);
RegisterRoutes(RouteTable.Routes);
}
private void RegisterViewEngine(ViewEngineCollection engines, RouteCollection routes)
{
SparkViewFactory engine = new SparkViewFactory();
RegisterFactory.DefaultRegister(IoCService.MyContainer, engine, routes);
engines.Add(engine);
}
How can I indicate that the page to render is html (Principal.html) and NOT spark extension?
Thanks in advance!
If you rename
Principal.htmltoPrincipal.sparkorPrincipal.html.sparkthat should fix it.Spark doesn't know that it should be looking for
.htmlfiles to render. I wouldn't recommend telling Spark to handle all.htmlfiles, but if you really want to, then you can implement your own CustomIDescriptorFilterimplementation to change the way that Spark locates views - but like I said, I wouldn't recommend it - I woud rather just rename.htmlfiles to.sparkthat you want Spark to pick upIs there a reason you cannot rename your html file extensions?