2015-10-08 21 views
6

3つのSQLデータベースを指すサーバー(IIS)上にMVCアプリケーションをホストしています。これは何ヶ月も問題なく実行されています。OWIN無効なURI:Uri文字列が長すぎます

すべての3つのSQLデータベースが新しいデータベースを指すように接続文字列を変更するだけで済みました。

は、今私は..私は次のエラーを取得するにはログインしようとすると、

enter image description here

接続文字列は、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); 
        } 
       } 
      } 
     }); 

    } 
} 
+0

あなたの 'Startup.cs'を表示 – haim770

+0

@ haim770謝罪私はそれを最初から含めておくべきです。 – heymega

+0

FiddlerやF12などを試して、ブラウザとサーバーの間のHTTPリクエストをキャプチャしましたか? –

答えて

1

数時間の調査の結果、私は結局その問題を発見しました。

問題は、ユーザーに追加されたクレーム数です。クレームの数を減らしたら、再び作業を開始しました。

0

最も可能性の高い原因は、あなたがエラーループ内で立ち往生しているということです。ユーザーが格納されているデータベースへの認証に失敗した場合は、エラーページに送信され、認証を再度実行して失敗し、エラーページに何度も送信されます。最終的にこの状態に達する前のURLに追加する各パス。

関連する問題