Visual Studio 2013にIIExpress(バージョン8.08418.0)でローカルに実行されているASP.NETプロジェクトがテスト用に用意されています。Response.Redirectは失敗しますが、IIS Expressを最新の状態に更新するVS2013
メインページ(adminDefault.aspx)は、認証するためにユーザーをLogin.aspxにリダイレクトします(adminDefault.aspxにURL変数として渡されたuserIDに基づいて自動的に行われます)。ログインページは、認証に成功するとadminDefault.aspxにそれを戻します。デフォルトでは、データがGridviewにロードされます。
全体の処理には約15秒かかります。
これをVisual Studio 2013から実行すると、約4秒で "このページを表示できません"というエラーが表示されます。しかし、私が手作業でリフレッシュすると、ちょっとした作業の後、すべてがうまくいきます。私のコードで
、タイムアウトを疑う、私は暗黙のうちに十分な長さのすべてを介して実行するために、これを設定します。
if (!this.IsPostBack)
{
Session.Timeout = 120; // seconds before timeout
try
{
// OnUser should have been set from Login.asp. If it is null, send to Login
MembershipUser onUser = Membership.GetUser();
if (onUser == null)
{
Response.Redirect("/login.aspx", true);
}
else
{
String currentUserName = Membership.GetUser().UserName;
userRoles = Roles.GetRolesForUser(Membership.GetUser().UserName);
}
}
Session.Timeoutは無視されている場合でも、デフォルトは20秒です私はそれがとにかく働くことを期待するでしょう。
So: 1)最初の実行に失敗したのはなぜですか? 2)私はそれを防ぐ方法がありますか?見つからないページをキャッチして自動的にリフレッシュできますか?
編集:これはLogin.aspxへの旅行と関係があります。削除した場合Response.Redirect("/login.aspx", true);
これは期待どおりに動作します。問題は、検証のためにLogin.aspxが必要なことです。誰でもログインとバックへの旅行がうまくいかない理由について考えてみてください...そしてリフレッシュするとどうなりますか?
これをChromeで実行しようとすると、私は遠くには行かない。一瞬のためにここにだけのサイクルを叩く
とバックスクリーンに来る:Chromeは私にこのことを示しています。
IEの開発者ツールは、このケースでは(少なくとも私が見ることは)役に立ちません。デバッガでプロジェクトを実行すると、新しいIEセッションが開始されます。開発ツールを有効にしてイベントを記録するために「再生」を押す前に、セッションで「ページを表示できません」というエラーが表示されました。もちろん、私はツールで "再生"してからリフレッシュすることはできますが、もちろんすべてがエラーなく実行されます。リフレッシュによってすべてが正しく実行されます。それ以前になぜ失敗するのかを知る必要があります。
EDIT:これはLogin.aspxとWeb.Security Codeです。私はそれを書いていないが、それは定型になります
protected void Page_Load(object sender, EventArgs e)
{
string userName = "";
bool authenticated = FormsAuthentication.Authenticate(ref userName);
if (authenticated)
{
FormsAuthentication.RedirectFromLoginPage(userName, false);
}
}
そして、認証コードは次のようになります。あなたは誰を想定しているなステートメントは、どちらかである場合、私はあなたの初期に考える
/// <summary>
/// Validates a user based on the session id found in the ReturnURL against credentials stored in the ASP.NET membership.
/// </summary>
/// <param name="userName">The user name.</param>
/// <returns>true if the user name and password are valid; otherwise, false.</returns>
public static bool Authenticate(ref string userName)
{
bool Authenticated = Authenticate(ref userName, GetSessionId());
return Authenticated;
}
/// <summary>
/// Redirects an authenticated user back to the originally requested URL or the default URL using the specified cookie path for the forms-authentication cookie.
/// </summary>
/// <param name="userName">The authenticated user name. </param>
/// <param name="createPersistentCookie">true to create a durable cookie (one that is saved across browser sessions); otherwise, false. </param>
/// <param name="strCookiePath">The cookie path for the forms-authentication ticket. </param>
public static void RedirectFromLoginPage(string userName, bool createPersistentCookie, string strCookiePath)
{
System.Web.Security.FormsAuthentication.SetAuthCookie(userName, false, strCookiePath);
// Redirect back to request page.
HttpContext.Current.Response.Redirect(GetRedirectUrl());
}
これを確認しましたか:https://stackoverflow.com/questions/18839409/asp-net-page-cant-be-displayed-error ???またはこれは:https://stackoverflow.com/questions/18706173/how-to-fix-this-page-cant-be-displayed-error-in-asp-net ??? – JCM
はい。どちらも適用されません。私はHttps(最初のリンクソリューション)を使用していません、そして、2番目のケースでは、それはlocalhostで動作しましたが、デプロイメントでは動作しませんでしたが、私の問題はlocalhostで発生します。 – MarkJoel60
ソリューションを展開するときに同じ問題がありますか? – JCM