使用AngularJS从ASP.NET MVC成员资格提供程序获取数据 [英] Getting Data From ASP.NET MVC Membership Provider With AngularJS

查看:50
本文介绍了使用AngularJS从ASP.NET MVC成员资格提供程序获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用内置的ASP.NET MVC成员资格提供程序来授权Web应用程序中的用户.我在随附的默认字段(电子邮件,密码)中添加了几个字段,例如名字,姓氏和客户编号.我可以注册并登录用户,但是现在我想为用户获取所添加字段的一些信息,并在我的AngularJS控制器中使用它.

So I am using the built in ASP.NET MVC membership provider for the authorization of users in my web application. I added several fields such as first name, last name and customer number to the default fields that it comes with (email, password). I am able to register and log in users but now I want to get some of the information of the added fields for the user and use it in my AngularJS controller.

我一直在学习AngularJS,并且已经成功使用WebAPI获取数据并将数据发布到服务器,但是我对如何获取登录到我的应用程序的当前用户的信息感到困惑.我假设它存储在某种会话令牌中,但我不知道如何从角度角度访问它并使用该信息.

I have been working with learning AngularJS and have been successful with using the WebAPI to get and post data to the server but I am stumped on how I can get the information of the current user who is signed in to my application. I am assuming it is stored in a session token of some sort but I do not know how to access it and work with that information from an angular standpoint.

感谢您的帮助,我可以提供所需的任何代码,但目前,我只拥有asp.net用于注册和登录用户的基本内置代码以及我的空角度控制器.谢谢.

Any help is appreciated, I can provide whatever code is necessary but at this point I only have the basic built in code that asp.net uses to register and login users and my empty angular controller. Thanks.

推荐答案

要从服务器端的任何位置获取当前用户,请使用

To get the current user from anywhere on the server side, use

HttpContext.Current.User.Identity.Name;

这篇关于使用AngularJS从ASP.NET MVC成员资格提供程序获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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