How to use Aurelia with cshtml views

I’m currently trying to build a proof of concept Aurelia app with webpack which will use cshtml views when required. I found this so question which essentially says that this may be possible given the ability for webpack to load dynamically.

Has anyone accomplished this that would be willing to share their solution/webpack configuration?

Thanks,
Matt

1 Like

I think this is not possible or easy to implement. If you have control over the .NET mvc controller, why not just have it return JSON of the data you need to build out your views, then just create your view the normal way and make an AJAX call to grab the JSON from .NET and build it that way?

Hey thanks for the reply.

I appreciate that there are ways around using the view locator but the plan is to utilize Razor and Html Helpers in our aurelia app in a manor which is easy to maintain. I know this is possible with system.js / require.js so was just hoping that some webpack wizard would be able to point me in the right direction. Frustratingly, I haven’t found a single thread/article that actually rules this out completely!

1 Like

You might have a look at this webpack plugin. https://github.com/jouni-kantola/razor-partial-views-webpack-plugin

1 Like

We should wait for SSR (Server side rendering)

Implement Server Render and Client Continue

Phase Four: ASP.NET Core Integration
With everything running in the native JavaScript environment, we then want to start branching out into other environments. .NET is a huge section of our community and we’ve got new customers in the .NET space whose plans are contingent on this feature. So, we want to work with Steve Sanderson and the JavaScriptServices project to get full integration of server render into their ASP.NET Core projects.
When this is done, we can probably ship v1.

I have created an architecture that combines asp.net mvc razor and aurelia using a razor first approach and the enhance feature of Aurelia. It uses taghelpers so there is a dependency on the asp.net core version of mvc and it does require a fair amount of plumbing but once setup it allows you to benefit from mvc concepts such as modelbinding, validation attributes and editor templates. Have a look at my blog, the posts point out a github repo you could fork and play with.
http://blog.deap.nu. Let me know what you think.

2 Likes