如何在Angular和C#ASP.NET之间传递信息? [英] How to pass info between Angular and C# ASP.NET?

查看:98
本文介绍了如何在Angular和C#ASP.NET之间传递信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将ASP.NET(aspx)用于Web应用程序的前端,并将C#用作后端&与数据库对话.但是,我更喜欢在Angular的前端工作,这确实缩短了我的开发时间.

I am using ASP.NET (aspx) for the frontend of my web apps and C# as the backend & to talk to the database. However, I much prefer working with Angular for my frontend and it really quickens my development time.

我目前对如何使用.NET创建Web应用程序的知识有很多ASPX代码,这些代码可以与我的C#代码自动通信.但是,我希望我的Angular/Javascript代码与我的C#通信(例如,发送用Angular编写的表单,然后由C#发布到我的数据库中).

My current knowledge of how to create web apps with .NET has a lot of ASPX code that communicates automatically with my C# code. However, I want my Angular/Javascript code to communicate with my C# (such as sending forms written in Angular to be posted by C# to my database).

我听说我可以使用AJAX来执行此操作,也可以使用诸如ScriptManager.RegisterClientScriptBlock之类的特殊功能.但是,我经验不足,无法直观地了解如何使其工作.有人可以(通过双方的代码示例)解释如何做到这一点吗?

I've heard I can use AJAX to do this, or special functions such as ScriptManager.RegisterClientScriptBlock. However, I am too inexperienced to intuitively find out how to make it work. Could someone please explain (with code examples from both sides) how this is done?

推荐答案

我假设您不是在说 ASP.Net Web表单,而AngularJS无法轻松使用它.

I assume you are not talking ASP.Net Web Form which cannot be used easily with AngularJS.

许多人将AngularJS与 ASP.Net Web API 一起使用,但有些人将ASP.Net MVC和Web API一起使用.

Many people use AngularJS with ASP.Net Web API, but some leverage with ASP.Net MVC and Web API together.

我个人喜欢 Mini SPA (Silos).您可以观看 AngularJS&ASP.NET MVC玩得很好-Miguel Castro .

I personally like Mini SPA (Silos). You can watch AngularJS & ASP.NET MVC Playing Nice - Miguel Castro.

您还可以在其网站上下载源代码.

You can also download the source at his website.

仅供参考: :我还使用具有ASP.NET MVC的强类型AngularJS应用.

FYI: I also use Angular.Net Helpers to generate strongly typed views. PluralSight has a course called Strongly-typed AngularJS Apps with ASP.NET MVC.

这篇关于如何在Angular和C#ASP.NET之间传递信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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