I need to implement some custom auth logic. In the AccountController
I wrote a method:
public async void ULogin()
{
EnsureDatabaseCreated(_applicationDbContext);
var token = Request.Form["token"];
HttpClient client = new HttpClient();
string query = Request.Scheme + "://ulogin.ru/token.php?token=" + "" + token + "" + "&host=" + "" + Request.Host;
string res = await client.GetStringAsync(query);
dynamic resObj = JsonConvert.DeserializeObject(res);
string _displayName = resObj.first_name + resObj.last_name;
string _uLoginIdentity = resObj.identity;
var user = _userManager.Users.Where(u => u.ULoginIdentity == _uLoginIdentity).FirstOrDefault();
//etc
}
While running the last line the System.ObjectDisposedException
appears. I also find out that Model and ChangeTracker properties of ApplicationDbContext
throw ObjectDisposedException
. Other methods in the controller work fine. I didn't change the controller's ctor or Startup. What might be the problem?
答案 0 :(得分:0)
解决。我应该将方法定义为public async Task ULogin()