Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine ASP MVC 5 and Emberjs

I am trying to experiment with ASP MVC 5 and Emberjs. I dont want to create full-fledge WebAPI that emberjs will serve. What I want is to mix both and use emberjs for data driven pages and razor view for simple pages.

So far I just tried ember-cli because I dont know how to build the emberjs app when combined with asp mvc.

My question is how to automatically import and compile the templates and js related to emberjs to be used on my asp mvc razor views?

Also I've read about es6 module in ember-cli, I dont know if its necessary to solve my problem.

like image 727
Jaime Sangcap Avatar asked Jul 13 '15 09:07

Jaime Sangcap


1 Answers

You'll likely want to use ember-cli to first build your Ember application using ember build (reference). Then ensure the output of build command (likely in the /dist folder unless you specified a different output path) is in a place that your Asp.Net MVC application has visibility of.

You can serve your newly built assets from your MVC application like this:

return File(Server.MapPath("~/my-ember-app/dist/") + "index.html", "text/html");

If your Ember application is located in the same folder as your Asp.Net MVC application each time you run ember build the new output should be sent to browser when the associate MVC route returns index.html.

like image 180
yohanmishkin Avatar answered Sep 28 '22 05:09

yohanmishkin