0

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!

tereško
  • 58,060
  • 25
  • 98
  • 150
Cintia
  • 1
  • 2
  • Is it static html? If so, could you just redirect to it? – Roman Oct 02 '13 at 13:27
  • Yes, it's static html and it's the initial page of the site. But in because of my proyect configuration I need to render the page through the controller...Thanks! – Cintia Oct 02 '13 at 13:30

1 Answers1

1

If you rename Principal.html to Principal.spark or Principal.html.spark that should fix it.

Spark doesn't know that it should be looking for .html files to render. I wouldn't recommend telling Spark to handle all .html files, but if you really want to, then you can implement your own Custom IDescriptorFilterimplementation to change the way that Spark locates views - but like I said, I wouldn't recommend it - I woud rather just rename .html files to .spark that you want Spark to pick up

Is there a reason you cannot rename your html file extensions?

RobertTheGrey
  • 8,645
  • 5
  • 32
  • 45