我已经使用MongoDB实现了自定义Identity 3.0提供程序。它在localhost中工作正常,但是当我将它上传到Azure时,我有这个错误:
处理请求时发生未处理的异常。
MissingMethodException:找不到方法:'无效 MongoDB.Driver.FindOptionsBase.set_AllowPartialResults(布尔)”。 MyProject.Web.Identity.UserStore`3.FindByNameAsync(字符串 normalizedUserName,CancellationToken cancellationToken)
RAW详情错误:
System.MissingMethodException:找不到方法:'Void MongoDB.Driver.FindOptionsBase.set_AllowPartialResults(Boolean)'。
在MyProject.Web.Identity.UserStore 3.FindByNameAsync(String normalizedUserName, CancellationToken cancellationToken)
at Microsoft.AspNet.Identity.UserManager
1.FindByNameAsync(String userName)
在Microsoft.AspNet.Identity.SignInManager`1.d__31.MoveNext()
在UserStore.cs中抛出错误的方法:
/// <summary>
/// Finds and returns a user, if any, who has the specified normalized user name.
/// </summary>
/// <param name="normalizedUserName">The normalized user name to search for.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be cancelled.</param>
/// <returns>
/// The <see cref="Task"/> that represents the asynchronous operation, containing the user matching the specified User if it exists.
/// </returns>
public virtual Task<TUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
if (string.IsNullOrWhiteSpace(normalizedUserName)) return Task.FromResult((TUser)null);
var filter = Builders<TUser>.Filter.Eq(x => x.Email, Normalize(normalizedUserName));
var options = new FindOptions { AllowPartialResults = false };
return DatabaseContext.UserCollection.Find(filter, options).SingleOrDefaultAsync(cancellationToken);
}
我已在localhost中测试连接到“生产数据库”,我没有这个错误,一切正常。
我正在使用MongoDb Driver C#2.1.1。
为什么在Localhost中工作而不在Azure中工作?如果删除AllowPartialResults会怎样?
感谢。