AspNetIdentity icon indicating copy to clipboard operation
AspNetIdentity copied to clipboard

Sign in windows development machine is working, after publish to linux - error String '' was not recognized as a valid DateTime.

Open kierepka opened this issue 4 years ago • 0 comments

Result:

 fail: Microsoft.AspNetCore.Server.Kestrel[13]
 Connection id "0HMCIB3PQJ72M", Request id "0HMCIB3PQJ72M:00000002": An unhandled exception was thrown by the application.
 System.FormatException: String '' was not recognized as a valid DateTime.
    at System.DateTimeParse.Parse(ReadOnlySpan`1 s, DateTimeFormatInfo dtfi, DateTimeStyles styles, TimeSpan& offset)
    at System.DateTimeOffset.Parse(String input, IFormatProvider formatProvider, DateTimeStyles styles)
    at System.DateTimeOffset.Parse(String input, IFormatProvider formatProvider)
    at Microsoft.Data.Sqlite.SqliteValueReader.GetDateTimeOffset(Int32 ordinal)
    at Microsoft.Data.Sqlite.SqliteValueReader.GetFieldValue[T](Int32 ordinal)
    at Microsoft.Data.Sqlite.SqliteDataRecord.GetFieldValue[T](Int32 ordinal)
    at Microsoft.Data.Sqlite.SqliteDataReader.GetFieldValue[T](Int32 ordinal)
    at lambda_method104(Closure , QueryContext , DbDataReader , ResultContext , SingleQueryResultCoordinator )
    at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
    at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
    at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
    at Microsoft.AspNetCore.Identity.UserManager`1.FindByNameAsync(String userName)
    at Microsoft.AspNetCore.Identity.SignInManager`1.PasswordSignInAsync(String userName, String password, Boolean isPersistent, Boolean lockoutOnFailure)
    at BioMindsXRSrv.Web.Controllers.UserController.Login(String userName, String password) in D:\GitHub\BioMindsXR_Srv\BioMindsXRSrv.Web\Controllers\UserController.cs:line 78
    at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
 --- End of stack trace from previous location ---
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
 --- End of stack trace from previous location ---
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
    at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
    at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Code for login:

var addInfo = string.Empty;
            if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
            {

[78line]                var result = await signInManager.PasswordSignInAsync(userName, password, false, false);
                addInfo = result.ToString();
                if (result.Succeeded)
                {
                    return Redirect("~/");
                }
            }

user:

    public class User : IdentityUser<Guid>
    {
        [DisallowNull]
        [Required]
        [PersonalData]
        public string FirstName { get; set; } = string.Empty;

        [DisallowNull]
        [Required]
        [PersonalData]
        public string LastName { get; set; } = string.Empty;

        [PersonalData]
        public UserSettings UserSettings { get; set; } = new UserSettings();

        [PersonalData]
        public ICollection<UserTherapy>? UserQuests { get; set; }
        [PersonalData]
        public bool IsAdmin { get; set; }
        [PersonalData]
        public bool IsDoctor { get; set; }
        [PersonalData]
        public Guid? DoctorId { get; set; }

        [NotMapped]
        public IEnumerable<string> RoleNames { get; set; }

        [IgnoreDataMember, NotMapped]
        public string Password { get; set; }

        [IgnoreDataMember, NotMapped]
        public string ConfirmPassword { get; set; }

        [IgnoreDataMember, NotMapped]
        public string Name
        {
            get => UserName;
            set => UserName = value;
        }
        [PersonalData]
        public string? HospitalName
        {
            get;
            set;
        }
        [PersonalData]
        public string? Phone
        {
            get;
            set;
        }

        [PersonalData]
        public DateTime? DateOfTheTest { get; set; }

        [PersonalData]
        public string? Diagnosis { get; set; }

        [PersonalData]
        public DateTime? DateOfDiagnosis { get; set; }

        [PersonalData]
        public DateTime? StartDateOfTherapy { get; set; }
        [PersonalData]
        public EHandiness? Handiness { get; set; }

        [PersonalData]
        public string? AdlScores { get; set; }

        [PersonalData]
        public string? BarthelResults { get; set; }

        [PersonalData]
        public string? NeuropsychologicalResults { get; set; }

        [PersonalData]
        public string? Other { get; set; }
    }

kierepka avatar Oct 18 '21 17:10 kierepka