混合 Angular 和 ASP.NET MVC/Web api? [英] Mixing Angular and ASP.NET MVC/Web api?

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

问题描述

我来自使用 ASP.NET MVC/Web API,现在我开始使用 Angular,但我不清楚混合它们的正确方法.

I come from using ASP.NET MVC/Web API and now I am starting to use Angular but I am not clear on the proper way to mix them.

一旦我使用了 Angular,MVC 服务器端的概念是否仍然提供任何价值?或者我应该严格地使用 Web API 来获取角 HTTP 调用的数据?

Once I am using Angular does the MVC sever side concepts still provide any value ? Or should I strictly be using Web API purely to get data for the angular HTTP calls ?

您对过渡到 Angular 的 ASP.NET MVC 人员的任何提示都会有所帮助

Any tips you have for a ASP.NET MVC guy transitioning to Angular would be helpful

推荐答案

Pure Web API

我曾经是 ASP.NET MVC 的核心,但自从我遇到了 Angular,我看不出为什么我会使用任何服务器端内容生成框架的一个原因.纯 Angular/REST(WebApi) 提供更丰富、更流畅的结果.它更快,并且允许您构建非常接近桌面应用程序的网站,而无需任何时髦的黑客攻击.

I used to be pretty hardcore with ASP.NET MVC but since I've met Angular I do not see one reason why I would use any server side content generation framework. Pure Angular/REST(WebApi) gives a richer and smoother result. It's much faster and allows you to build websites that come quite close to desktop applications, without any funky hacks.

Angular 确实有一点学习曲线,但是一旦您的团队掌握了它,您将在更短的时间内构建更好的网站.这主要与您不再有所有这些状态(较少)问题的事实有关.

Angular does have a little learning curve, but once your team has mastered it, you'll build much better websites in less time. Mainly this has to do with the fact that you don't have all these state(less) issues anymore.

例如,想象一个带有任何传统服务器端框架的向导表单.每个页面都需要单独验证和提交.也许页面的内容取决于上一页的值.也许用户按下了后退按钮并重新提交了以前的表单.我们在哪里存储客户端的状态?使用 Angular 和 REST 时,所有这些复杂情况都不存在.

For example imagine a wizard form with any traditional server side framework. Each page needs to be validated and submitted separately. Maybe the content of the page is dependent on values from a previous page. Maybe the user pressed the back button and is re-submitting an previous form. Where do we store the state of the client? All these complications do not exist when using Angular and REST.

所以......来到黑暗的一面......我们有饼干.

So ... come over to the dark side ... we've got cookies.

类似问题

这篇关于混合 Angular 和 ASP.NET MVC/Web api?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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