I'm wondering why not just have static HTML files in an ASP.Net MVC 4 Web Project that use jQuery+jQuery Templates+KnockoutJS combination consuming REST based (ASP.Net MVC 4 WEB API hosted on Azure & secured using ACS). The Web API can use Entity Framework and return JSON serialized objects that can be retrieved using $.ajax() and bound using KnockoutJS.

我想知道为什么不在ASP.Net MVC 4 Web项目中使用静态HTML文件,这些文件使用jQuery + jQuery模板+ KnockoutJS组合消费基于REST(在Azure上托管的ASP.Net MVC 4 WEB API并使用ACS保护)。 Web API可以使用Entity Framework并返回可以使用$ .ajax()检索并使用KnockoutJS绑定的JSON序列化对象。

What is it that ASP.Net MVC (for the Web pages) provides that adds value to this architecture?
On top of my head, I can think of:

什么是ASP.Net MVC(用于网页)提供了为这种架构增加价值?在我的头顶,我能想到:

  1. Multi device support (device detection and template replacement)
  2. 多设备支持(设备检测和模板更换)

  3. Server-side validations of submitted data (not sure as I can also put the validations on WEB API?)
  4. 提交数据的服务器端验证(不确定,因为我也可以将验证放在WEB API上?)

  5. I can still rewrite my URLs even if I'm using static html files (since I'm using ASP.Net MVC anyway).
  6. 即使我使用的是静态html文件,我仍然可以重写我的URL(因为我正在使用ASP.Net MVC)。

Can someone help me understand this better? Thanks in advance.

有人能帮助我更好地理解这一点吗?提前致谢。

5 个解决方案

#1


7

Great question. I'm certainly finding that my MVC / Razor code is becoming less and less as I progress with my Knockout project, but I think I'll always have some aspects of the views which I want to be determined server-side.

好问题。我肯定发现我的MVC / Razor代码随着我的Knockout项目的进展而变得越来越少,但我想我总是会看到一些我希望在服务器端确定的视图方面。

Fundamental contextual stuff like whether to render a logged in / logged out panel in a layout page, role related decisions as to what should be accessible, etc. I guess if you were careful enough with your security and implement sufficient guard code on the server when someone actually tries to do something then you could achieve most of that in Knockout, but you'd probably end up with a huge amount of bloat, catering for every possible part of the view.

基本的上下文内容,例如是否在布局页面中呈现登录/注销面板,与角色相关的决定应该可以访问的内容等等。我猜你是否对你的安全性足够小心,并在服务器上实现足够的保护代码时有人实际上试图做一些事情,然后你可以在Knockout中实现大部分,但你可能最终会有大量的膨胀,迎合视图的每一个可能的部分。

It probably depends on your application but I think for most web apps there's a fairly common sense division between what should be determined at server render time and what should be done on the client.

它可能取决于您的应用程序,但我认为对于大多数Web应用程序而言,在服务器呈现时间应确定的内容与客户端应执行的操作之间存在相当常识。

If nothing else, you may want links etc in your views to be indexed by search engines. If you pass down, say, your "latest 10 products" in JSON and render them with hyperlinks in a Knockout template, you'd lose out on that.

如果不出意外,您可能希望视图中的链接等被搜索引擎编入索引。如果你传下来,比如你在JSON中的“最新的10个产品”,并在Knockout模板中用超链接渲染它们,你就会失败。

更多相关文章

  1. 如何为django模板中的标记创建动态id
  2. HTML5实现一个可编辑的模板页面
  3. 儿童视图不在angular-ui-router中工作
  4. 为什么我不用Javascript和Javascript HTML模板构建整个Web应用程
  5. 可以将Eclipse配置为防止某些警告出现在Problems视图窗格中吗?
  6. 在Codeigniter中将javascript变量从视图发送到控制器[重复]
  7. PHP连接mysql模板
  8. 在php项目中, mysql视图常用吗?
  9. 从PHP智能模板中剥离空白

随机推荐

  1. Android的Activity启动流程分析
  2. Android保持屏幕常亮
  3. Android中文语音合成(TTS)各家引擎对比 .
  4. android gradle 配置 build.gradle
  5. Qt for Android(九) ——APP 崩溃卡死拉起
  6. Android(安卓)网络连接:Volley(齐射)之简单
  7. Android之service一些基础回顾
  8. android ContentResolver
  9. Android(安卓)TV,机顶盒Gridview 焦点
  10. 『Android』activity的生命周期