Description
I trying to use the IdentityServer3.Contrib.Localization.UI to provide localization for UI but when i put the code below in StartUp.cs Configuration
var embeddedViewServiceConfig = new DefaultViewServiceOptions();
var factory = new IdentityServerServiceFactory();
factory.ViewService = new Registration<IViewService>(
resolver => new DefaultViewService(, new LocalizedViewLoader()));
I faced the below Exception:
{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":" at IdentityServer3.Contrib.Localization.UI.TranslatorHelper.Translate(String html) in c:\\_work\\IdentityServer3.Contrib.Localization.UI\\IdentityServer3.Contrib.Localization.UI\\source\\IdentityServer3.Contrib.Localization.UI\\TranslatorHelper.cs:line 95\r\n at IdentityServer3.Contrib.Localization.UI.LocalizedViewLoader.<LoadAsync>d__0.MoveNext() in c:\\_work\\IdentityServer3.Contrib.Localization.UI\\IdentityServer3.Contrib.Localization.UI\\source\\IdentityServer3.Contrib.Localization.UI\\LocalizedViewLoader.cs:line 38\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at IdentityServer3.Core.Services.Default.DefaultViewService.<Render>d__8.MoveNext() in c:\\local\\identity\\server3\\Core\\source\\Core\\Services\\DefaultViewService\\DefaultViewService.cs:line 220\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at IdentityServer3.Core.Results.ErrorActionResult.<>c__DisplayClass2.<<.ctor>b__0>d__4.MoveNext() in c:\\local\\identity\\server3\\Core\\source\\Core\\Results\\ErrorActionResult.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at IdentityServer3.Core.Results.HtmlStreamActionResult.<Render>d__0.MoveNext() in c:\\local\\identity\\server3\\Core\\source\\Core\\Results\\HtmlStreamActionResult.cs:line 37\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at IdentityServer3.Core.Results.HtmlStreamActionResult.<GetResponseMessage>d__5.MoveNext() in c:\\local\\identity\\server3\\Core\\source\\Core\\Results\\HtmlStreamActionResult.cs:line 42\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at IdentityServer3.Core.Configuration.Hosting.ErrorPageFilterAttribute.<OnExceptionAsync>d__1.MoveNext() in c:\\local\\identity\\server3\\Core\\source\\Core\\Configuration\\Hosting\\ErrorPageFilterAttribute.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ExceptionFilterAttribute.<ExecuteExceptionFilterAsyncCore>d__0.MoveNext() in c:\\local\\identity\\server3\\Core\\source\\Core\\Validation\\HashedSharedSecretValidator.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext() in c:\\local\\identity\\server3\\Core\\source\\Core\\Validation\\HashedSharedSecretValidator.cs:line 0\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext() in c:\\local\\identity\\server3\\Core\\source\\Core\\Validation\\HashedSharedSecretValidator.cs:line 0"}
I want to mention also that i used: https://github.com/johnkors/IdentityServer3.Contrib.Localization for scope, messages, and events localization