我的登录方法在本地主机上正确运行,但是当我在服务器上发布时,出现ArgumentNullException错误

E:\ mylocaldirectory \ myassembly \ Controllers \ M_AccountController.cs:179中的mynamespase.Controllers.d__11.MoveNext()

奇怪的是,为什么错误在服务器上显示我的本地地址,为什么我的代码在localhost上正确运行,但在服务器上使用相同的代码却有错误

实际上,我真正的问题是这一行“ E:\ mylocaldirectory \ myassembly \ Controllers \ M_AccountController.cs:179”
[这是我的错误图片] [https://i.stack.imgur.com/IUBTP.jpg]

[HttpPost]
        public virtual async Task<ActionResult> Check_Code_4_Login(string code, string phoneNumber, string returnUrl)
        {
            var baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority;

            var dtNow = DateTime.Now;
            var _code = Convert.ToInt32(code);

            var userActiveCode = await _userActiveCodeService
                .FindFirstAsync(p =>
                    p.PhoneNumber == phoneNumber &&
                    p.ActiveCode == _code &&
                    p.ActiveCodeExpireDate > dtNow &&
                    p.Used == false &&
                    p.Enabled);

            if (userActiveCode == null)
            {
                TempData["Error"] = "Code Incorrect";
                return RedirectToAction(nameof(PostedLogin),new {phoneNumber=phoneNumber, reagentCode="",returnUrl="" });
            }

            var user = await _userManager.FindByPhoneNumberAsync(userActiveCode.PhoneNumber);
            if (user == null)
            {
                    var _user = new User
                    {
                        UserName = phoneNumber,
                        PhoneNumber = phoneNumber,
                        RegisterDate = dtNow
                    };
                    var res = await _userManager.CreateAsync(_user);

                    if (res == IdentityResult.Success)
                    {
                        user = _user;

                        await _userManager.AddToRoleAsync(user.Id, "Customer");
                    }
                    else
                    {
                        //todo Error
                        throw new Exception("Registeration Error");
                    }

            }

            await _signInManager.SignInAsync(user, true, true);

            var userIdentity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);


            return Redirect(returnUrl != null ? returnUrl : baseUrl);
        }```

I expect the output of the login method to be login user on the server or have an error on local, but the actual output is login user on local and have an error on server


最佳答案

实际上这些是您的程序集发布的位置
它与您的本地计算机无关,如果您尝试使用其他客户端,则会看到相同的内容

10-08 19:22