Ember CLI 和 ASP.NET [英] Ember CLI and ASP.NET

查看:27
本文介绍了Ember CLI 和 ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过引用 ember.js 文件,我已经成功地将 EmberJS JavaScript 框架与 ASP.NET Web 应用程序一起使用.

I've successfully used the EmberJS JavaScript framework with an ASP.NET web application, by referencing ember.js file.

我的印象是 Ember-CLI 是 Ember 在未来版本中的发展方向.

I'm under the impression that Ember-CLI is the way Ember will be heading in future versions.

如果这是正确的,那么继续使用 Ember 的合适方法是什么?将 Ember-CLI 与 ASP.NET 一起使用是否有意义,或者假设客户端只是回调服务器端代码(例如 WebAPI)的静态 HTML 和 CSS/JS?

If this is correct, what's the appropriate way to keep using Ember going forward? Does it make sense to use Ember-CLI with ASP.NET, or is the assumption that the client is only ever static HTML and CSS/JS that calls back to server-side code (eg. WebAPI)?

推荐答案

Ember-Cli 只是 Ember 社区祝福"的命令行工具链,因此它实际上只是构建 ember 应用程序的一种不同方式.

Ember-Cli is just the command line toolchain that the Ember community is "blessing", so it's really just a different way of building the ember app.

我实际上将 Ember-Cli 与 ASP.NET MVC 和 WebApi 一起使用.基本上我正在做的是使用 EmberCLI 输出一个 index.html 文件(ember new myapp 默认设置一个项目来执行此操作),然后让我的 MVC 应用程序路由到/App url,其中控制器返回一个 View("~/whateverdirectory/myapp/dist/index.html"); Razor 不关心你返回的视图不是 .cshtml 文件,所以这个工作正常,特别是如果您使用 Ember 来控制整个页面.这样就可以使用ASP.NET中的标准身份验证,然后当用户登录后,通过MVC将它们发送到App控制器的索引路由,并为它们提供Ember应用程序.

I'm actually using Ember-Cli with ASP.NET MVC and WebApi. Essentially what I'm doing is using EmberCLI to output an index.html file (ember new myapp sets up a project to do this by default), and then having my MVC app route to an /App url, where the controller returns a View("~/whateverdirectory/myapp/dist/index.html"); Razor doesn't care that the view you return isn't a .cshtml file, so this works fine, particularly if you're using Ember to control the whole page. This way you can use the standard authentication in ASP.NET, and then when the user is logged in, send them to the App controller's index route through MVC, and serve them the Ember app.

2015 年 8 月 18 日更新

我在 github 上添加了一些示例代码.

I've added some sample code on github.

这篇关于Ember CLI 和 ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆