Tôi có một ứng dụng MVC được lưu trữ trên một máy chủ (IIS) trỏ đến 3 cơ sở dữ liệu SQL. Điều này đã được chạy mà không có vấn đề trong nhiều tháng.OWIN Invalid URI: Chuỗi Uri quá dài
Tôi vừa phải thay đổi kết nối cho tất cả 3 cơ sở dữ liệu SQL để trỏ đến cơ sở dữ liệu mới.
Bây giờ khi tôi cố gắng đăng nhập tôi nhận được lỗi sau ..
Các chuỗi kết nối đang sử dụng Windows Authentication và tài khoản này được thiết lập trong AppPool. Tôi cũng đã tự cố gắng kết nối với từng cá thể cơ sở dữ liệu với tài khoản và điều này hoạt động tốt. Tôi bắt đầu nghĩ rằng sự thay đổi là các kết nối SQL chỉ là một cá trích đỏ.
Trong điều khoản của thông báo lỗi, tôi hoàn toàn hiểu được lỗi là gì Im chỉ không chắc chắn lý do tại sao nó bị ném. Điều duy nhất tôi có thể nghĩ đến là tôi đang ở trong một loại vòng lặp chuyển hướng nào đó đang thêm URL.
Nó chắc chắn cảm thấy giống như một vấn đề IIS nhưng tôi không thể đặt ngón tay của tôi trên đó.
Có ai gặp điều này trước đây với OWIN hoặc có thể tư vấn về các bước gỡ lỗi có thể chẩn đoán sự cố không?
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);
}
}
}
});
}
}
Hiển thị 'Startup.cs' của bạn – haim770
@ haim770 Xin lỗi tôi nên bao gồm điều đó để bắt đầu. – heymega
Bạn đã thử Fiddler hoặc F12 vv để nắm bắt các yêu cầu http giữa trình duyệt và máy chủ chưa? –