OWIN URI无效:Uri字符串太长

hey*_*ega 6 sql-server iis asp.net-mvc owin

我有一个托管在服务器(IIS)上的MVC应用程序,它指向3个SQL数据库.几个月来,这一直没有问题.

我只需要将所有3个SQL数据库的连接字符串更改为指向新数据库.

现在,当我尝试登录时,我收到以下错误..

在此输入图像描述

连接字符串使用Windows身份验证,此帐户在AppPool中设置.我还手动尝试使用该帐户连接到每个数据库实例,这很好.我开始认为改变是SQL连接只是一个红色的鲱鱼.

在错误消息方面,我完全理解错误是什么我只是不确定为什么它被抛出.我唯一能想到的是我在某种重定向循环中附加了URL.

这肯定感觉像是一个IIS问题,但我不能指责它.

有没有人在使用OWIN之前遇到过这个问题,或者可以就可能诊断问题的调试步骤提出建议?

Startup.cs

public partial class Startup
{
    private static bool IsAjaxRequest(IOwinRequest request)
    {
        IReadableStringCollection query = request.Query;
        if ((query != null) && (query["X-Requested-With"] == "XMLHttpRequest"))
        {
            return true;
        }
        IHeaderDictionary headers = request.Headers;
        return ((headers != null) && (headers["X-Requested-With"] == "XMLHttpRequest"));
    }


    public void ConfigureAuth(IAppBuilder app)
    {
        // Configure the db context, user manager and role manager to use a single instance per request
        app.CreatePerOwinContext(ParentDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.Create);
        app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
        app.CreatePerOwinContext(PrincipalManager.Create);

        // Enable the application to use a cookie to store information for the signed in user
        // and to use a cookie to temporarily store information about a user logging in with a third party login provider
        // Configure the sign in cookie
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            Provider = new CookieAuthenticationProvider
            {
                // Enables the application to validate the security stamp when the user logs in.
                // This is a security feature which is used when you change a password or add an external login to your account.  
                OnValidateIdentity =
                    SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser, Guid>(
                        TimeSpan.FromMinutes(int.Parse(WebConfigurationManager.AppSettings["RefreshInterval"])),
                        (manager, user) => manager.GenerateUserIdentityAsync(user),
                        claim => new Guid(claim.GetUserId())),
                OnApplyRedirect = ctx =>
                {
                    if (!IsAjaxRequest(ctx.Request))
                    {
                        ctx.Response.Redirect(ctx.RedirectUri);
                    }
                }
            }
        });

    }
}
Run Code Online (Sandbox Code Playgroud)

hey*_*ega 1

经过几个小时的调查,我最终发现了问题。

问题在于为用户添加的索赔数量。一旦我们减少了索赔数量,它就又开始起作用了。