Sto cercando di implementare la reimpostazione della password su un sito Web ASP.NET MVC basato su OWIN/Katana in esecuzione in Azure.L'operazione di protezione dati non è andata a buon fine in Azure utilizzando OWIN/Katana
Funziona correttamente quando viene eseguito localmente ma non riesce nella produzione.
ho creare un provider UserToken
userManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(provider.Create("PasswordReset"))
Ma quando tento di generare il token come segue ottengo uno spettacolo un'eccezione alla fine.
var resetToken = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
System.Security.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope)
at System.Security.Cryptography.DpapiDataProtector.ProviderProtect(Byte[] userData)
at System.Security.Cryptography.DataProtector.Protect(Byte[] userData)
at Microsoft.Owin.Security.DataProtection.DpapiDataProtector.Protect(Byte[] userData)
at Microsoft.AspNet.Identity.Owin.DataProtectorTokenProvider`2.<GenerateAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.Identity.UserManager`2.<GenerateUserTokenAsync>d__e9.MoveNext()
hai trovato la soluzione? – Dragouf
Nota ancora. Qualche idea? –
sì, ho trovato una soluzione, ma non sono totalmente soddisfatto. Sembra che sia dovuto al parametro AppName che non è lo stesso ovunque nell'applicazione. Quindi ho usato i parametri dell'app della chiamata di configurazione (app IAppBuilder) da OwinStartupAttribute per installare l'IDataPRovider e sembra funzionare. Per ottenere l'oggetto dataprovider puoi farlo in questo modo: app.GetDataProtectionProvider(). Dimmi se funziona – Dragouf