如何将值从Javascript传递到我的Mvc控制器? [英] How Do I Pass Values From Javascript To My Mvc Controller ?

查看:76
本文介绍了如何将值从Javascript传递到我的Mvc控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将值从javascript传递给我的MVC控制器?

实际上我正试图在我的应用程序中使用google和facebook登录。我得到了一些代码和它的工作。但它是客户端。

所以现在有一些javascript函数会在成功登录google \facebook时被调用。我可以使用javascript获取登录的用户名,图像等。

但我想在我的C#侧获取这些信息。这是在我的控制器中,因为我想在我的本地保存这些信息DB table.SO如何将这些值传递给控制器​​?

我想我可以使用json传递这些值,但是如何?

我怎样才能得到图像用户?

如果有任何其他方法使用google \facebook使用c#代码而不是javascript,请帮助我告诉我。

How do i pass values from javascript to my MVC controller ?
Actually am trying to implement sign in with google and facebook in my application.I got some code and its working.But it is client side.
So now some javascript functions are there which will get called on successful login of google\facebook. I can get the logged in user name,image etc as well using the javascript.
But i want these info in my C# side.That is in my controller because i want to save these info in my local DB table.SO how can i pass these values to controller ?
I think i can use json to pass these value, but how ?
How can i get the image of the user?
Please help also let me know if there any other ways to do this sign using google\facebook using c# code instead of javascript.

推荐答案

当然,MVC不仅指建筑模式,还指 ASP.NET MVC框架 实现它。



JavaScript与服务器端通信的方式是通过AJAX发送一些HTTP请求:http://en.wikipedia.org/wiki/Ajax_%28programming%29 [ ^ ]。



你可以从这里开始: https://msdn.microsoft.com/en-us/library/ dd381533%28v = vs.100%29.aspx [ ^ ]。



-SA
Most certainly, by "MVC" you mean not just the architectural pattern, but ASP.NET MVC Framework implementing it.

The way JavaScript communicates with server side is sending some HTTP requests via AJAX: http://en.wikipedia.org/wiki/Ajax_%28programming%29[^].

You can start here: https://msdn.microsoft.com/en-us/library/dd381533%28v=vs.100%29.aspx[^].

—SA

这篇关于如何将值从Javascript传递到我的Mvc控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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