我在使用Internet Explorer或edge提交表单时遇到问题。该表单在Chrome和Firefox中均可提交。问题似乎来自OpenIdConnect授权流程,但我很难将其隔离,特别是因为它适用于其他浏览器。
该应用程序使用Azure AD进行身份验证。
所以,这是html:
<div class="form form-horizontal form-validate block block-size-a auto-form-submit">
@using (Html.BeginForm("Search", "Users", FormMethod.Post))
{
<div class="control-group control-group-odd">
<div class="control-label">
<label for="searchText">Search</label>
</div>
<div class="controls">
<input class="input-xlarge" type="text" placeholder="Names and Emails" name="searchText" value="@Model.SearchText">
</div>
</div>
if (ViewBag.UserIsSA)
{
<div class="control-group control-group-odd">
<div class="control-label">
<label for="clientId">Client</label>
</div>
<div class="controls">
<select class="input-xlarge auto-form-submit-select" name="clientId">
<option value="0">Show all</option>
@foreach (var item in Model.Clients)
{
<option value="@item.Id" @(item.Id == Model.SelectedClientId ? "selected" : "")>@item.Name (@item.ClientNumber)</option>
}
</select>
</div>
</div>
}
<div class="control-group control-group-odd">
<div class="controls">
<button type="submit" class="btn btn-alt btn-style-e">Filter</button>
</div>
</div>
}
</div>
这是表单提交的方法:
public async Task<ActionResult> Index(string searchText = "", int clientId = 0, int page = 1, int pageSize = 10)
{
...
}
我已经检查了请求,并且似乎设置了正确的值,但它从未达到IE中的方法
这是错误。
>应用程序中的服务器错误。值不能为空。参数名称:参数说明:An 在执行当前Web期间发生了未处理的异常 请求。请查看堆栈跟踪以获取有关的更多信息 错误以及它在代码中的起源。
异常详细信息:System.ArgumentNullException:值不能 空值。参数名称:参数
来源错误:
执行期间生成了未处理的异常 当前的网络请求。有关的来源和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。
堆栈追踪:
[ArgumentNullException:Value不能为null。参数名称: 参数]
Microsoft.IdentityModel.Protocols.AuthenticationProtocolMessage.SetParameter(字符串 参数,字符串值)+138
Microsoft.IdentityModel.Protocols.OpenIdConnectMessage..ctor(IEnumerable`1 参数)+124
Microsoft.Owin.Security.OpenIdConnect.d__1a.MoveNext() +1063 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)+99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)+58
Microsoft.Owin.Security.OpenIdConnect.d__34.MoveNext() +154 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)+99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)+58
Microsoft.Owin.Security.Infrastructure.d__0.MoveNext()+383
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)+99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)+58
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext() +187 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)+99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)+58
Microsoft.Owin.Security.Infrastructure.d__0.MoveNext()+561
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)+99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)+58
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__5.MoveNext() +187 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)+99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)+58
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.d__2.MoveNext() +185 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult) ar)+69
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult的 ar)+64
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +380 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&amp; completedSynchronously)+155
为了完整性,我认为它可能是相关的,这是我的Startup.Auth.cs文件中的代码:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
LoginPath = new PathString("/Tour")
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
AuthenticationMode = AuthenticationMode.Passive,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
//
// If there is a code in the OpenID Connect response, redeem it for an access token and refresh token, and store those away.
//
AuthorizationCodeReceived = async (context) =>
{
var code = context.Code;
// Create a Client Credential Using an Application Key
ClientCredential credential = new ClientCredential(clientId, appKey);
string userObjectID = context.AuthenticationTicket.Identity.FindFirst(
"http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
AuthenticationContext authContext = new AuthenticationContext(authority, new NaiveSessionCache(userObjectID));
AuthenticationResult result = await authContext.AcquireTokenByAuthorizationCodeAsync(
code, new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path)), credential, graphResourceId);
AuthenticationHelper.token = result.AccessToken;
}
}
});
}
因此,看起来好像将一个空值传递给
Microsoft.IdentityModel.Protocols.AuthenticationProtocolMessage.SetParameter(String parameter, String value)
但是它来自哪里,为什么我在非微软浏览器中没有问题?
修改 每当我尝试将表单数据发布到操作时,就会在整个应用程序中发生这种情况。
任何帮助表示赞赏