【发布时间】:2016-07-06 18:58:41
【问题描述】:
我有一个WebMatrix 应用程序,我正在使用WebSecurity.GetUserId(Http.Current.User.Identity.Name) 来获取UserID。有时它返回UserId,有时它返回-1。因此,我有一个登录页面,它应该获取登录到应用程序的人的UserId。
这是我的代码:
var UserId = WebSecurity.GetUserId(HttpContext.Current.User.Identity.Name);
var User = WebSecurity.CurrentUserName;
var UserEmail = WebSecurity.CurrentUserName;
var dbApp = Database.Open("ApplicationServices");
var selectUser = "SELECT UserId, UserName, Location FROM LocationTable, UserTable WHERE (UserId) = (@0) AND (UserLocation) = (Id)";
var person = dbApp.QuerySingle(selectUser, UserId);
为什么不一致?
【问题讨论】:
标签: sql-server security razor webmatrix