Aurelia Server Side Views (ASP.NET MVC)

I'm brand new to Aurelia. I was able to get Aurelia up and running and the ASP.NET MVC application started and now I want to get a view of the Aurelia element using an ASP.NET MVC activity. I've seen several examples using either useView, getViewStrategy, or ViewLocator, but while the examples mention ASP.NET MVC or Razor, they all seem to use static HTML.

My findings:

useView

@useView('/Issue/EditIssueHtml') 
export class EditIssue {

      

Vulnerability in View only supports static HTML: unhandled rejection Error: Load time for modules: template-registry-entry! / Issue / EditIssueHtml, text! / Issue / EditIssueHtml

getViewStrategy

export class EditIssue {
    getViewStrategy() {
        return '/Issue/EditIssueHtml';
    }
}

      

The method only works for the root of the application (it is never called for elements). However, using it with the application root and ASP.NET MVC action throws the same error as using useView, assuming only static HTML is supported.

ViewLocator

ViewLocator.prototype.convertOriginToViewUrl = (origin: Origin) => {
  var moduleId: string = origin.moduleId;
  var name = moduleId.split('/')[moduleId.split('/').length - 1].replace('ViewModel', 'View').replace('.js', '').replace('.ts', '');
  console.log('ViewLocator: ' + name);
  if (name !== 'edit-issue') {
    return `${name}.html`;
  }
  return "/Issue/EditIssueHtml";
}

      

The same errors as in useView.

I found a question on Aurelia side side views: Adding an auth header to the HTTP view / viewmodel upload request , where the developer claims to have created a working solution based on the Aurelia documentation at http://aurelia.io/hub.html#/doc/article / aurelia / framework / latest / app-configuration-and-startup / 9 , but the documentation doesn't say anything about server side views.

Am I missing something or does Aurelia not support server side views?

+3


source to share


1 answer


From my professional life with Aurelia, I don't recommend using it with MVC and Razor.

I've been trying to do this for almost a year now and I just can't get past the npm stuff in visual studio.

My suggestion is to avoid Aurelia with server side rendering. It will only haunt you in your sleep every night.

In my long career with Aurelia, I have spent almost 2 days building a SPA and it works great.



If I were you, I would take the spa road.

To answer your question, it's not even possible to render with Aurelia.

Good luck.

+1


source







All Articles