我有一个托管在指向3个SQL数据库的服务器(IIS)上的MVC应用程序。这几个月来一直没有问题。OWIN无效的URI:Uri字符串太长
我只需要更改所有3个SQL数据库的连接字符串以指向新的数据库。
现在,当我尝试登录我碰到下面的错误..
连接字符串使用Windows身份验证与此帐户的应用程序池设置。我也手动尝试连接到每个数据库实例与帐户,这工作正常。我开始认为这种变化是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);
}
}
}
});
}
}
显示你的'Startup.cs' – haim770
@ haim770道歉我应该包括那开始。 – heymega
您是否尝试过Fiddler或F12等来捕获浏览器和服务器之间的http请求? –