Asp.net core mvc 使用Identity Server 4登录SharePoint 2013时出错
尝试使用Identity Server 4登录SharePoint 2013时出错,这是一个错误“此方法只能在System.Web.HttpRequest.get_LogonUserIdentity()+258的身份验证事件Asp.net core mvc 使用Identity Server 4登录SharePoint 2013时出错,asp.net-core-mvc,sharepoint-2013,identityserver4,Asp.net Core Mvc,Sharepoint 2013,Identityserver4,尝试使用Identity Server 4登录SharePoint 2013时出错,这是一个错误“此方法只能在System.Web.HttpRequest.get_LogonUserIdentity()+258的身份验证事件后调用” 在IIS上托管identity server mvc core应用程序时发生错误。从VisualStudio运行时,它工作正常。有人能提供建议或帮助吗 编辑: 这是帐户控制器中的登录操作 [HttpGet] public async Task<IAct
后调用”
在IIS上托管identity server mvc core应用程序时发生错误。从VisualStudio运行时,它工作正常。有人能提供建议或帮助吗
编辑:
这是帐户控制器中的登录操作
[HttpGet]
public async Task<IActionResult> Login(string returnUrl)
{
var vm = await _account.BuildLoginViewModelAsync(returnUrl);
if (vm.IsExternalLoginOnly)
{
// only one option for logging in
return await ExternalLogin(vm.ExternalProviders.First().AuthenticationScheme, returnUrl);
}
if(!string.IsNullOrEmpty(Request.Query["culture"])) ViewBag.QueryString = Request.QueryString.Value.Replace("&culture=en", "").Replace("&culture=ar", "") + "&culture=" + Request.Query["culture"];
else ViewBag.QueryString = Request.QueryString.Value.Replace("&culture=en", "").Replace("&culture=ar", "") + "&culture=en";
return View(vm);
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Login(LoginInputModel model)
{
if (ModelState.IsValid)
{
// validate username/password against in-memory store
if (_users.CheckPassword(model.Username, model.Password))
{
AuthenticationProperties props = null;
// only set explicit expiration here if persistent.
// otherwise we reply upon expiration configured in cookie middleware.
if (AccountOptions.AllowRememberLogin && model.RememberLogin)
{
props = new AuthenticationProperties
{
IsPersistent = true,
ExpiresUtc = DateTimeOffset.UtcNow.Add(AccountOptions.RememberMeLoginDuration)
};
};
// issue authentication cookie with subject ID and username
var user = _users.Find(model.Username);
await HttpContext.Authentication.SignInAsync(user.SubjectId, user.UserName, props);
// deleteCookie();
// HttpContext.Response.Cookies.Append("FedAuth", "", new CookieOptions() { Expires = DateTime.Now.AddDays(-1) });
// make sure the returnUrl is still valid, and if yes - redirect back to authorize endpoint
if (_interaction.IsValidReturnUrl(model.ReturnUrl))
{
return Redirect(model.ReturnUrl);
}
return Redirect("~/");
}
ModelState.AddModelError("", AccountOptions.InvalidCredentialsErrorMessage);
}
ViewBag.QueryString = Request.QueryString.Value;
// something went wrong, show form with error
var vm = await _account.BuildLoginViewModelAsync(model);
return View(vm);
}
版本信息:Microsoft.NET Framework版本:4.0.30319;ASP.NET版本:4.6.1087.0
我已经能够通过修改SharePoint站点的重定向Url并将default.aspx从Url中删除为http://{{SP site}}/{u trust而不是http://{{SP site}}/{u trust/default.aspx你能发布你的代码吗?@moritzg我已经在问题中添加了身份验证逻辑,如果您需要更多详细信息,请告诉我错误的完整堆栈跟踪也会很有帮助!我添加了错误详细信息和错误完整堆栈OK奇怪的错误,我在
Release
和Debug
之间切换时遇到了类似的问题,因此我建议您清理项目,并尝试使用Release
在本地运行它?并检查Release
和Debug