2

IIS 7 のマネージ モジュールから C# でフレーム リダイレクトを実行したいと考えています。
呼び出すとcontext.Response.Redirect(@"http://www.myRedirect.org");、正しいページが表示されますが、アドレスもブラウザーに表示されます。そして、それはまさに私が望んでいないことです。
だから私は次のようなものが欲しい:

private void OnBeginRequest(object sender, EventArgs e)
{
    HttpApplication app = (HttpApplication)sender;
    HttpContext context = app.Context;

    // make a frame redirect if a specified page is called
    if (context.Request.ServerVariable["HTTP_REFERER"].Equals(@"http://www.myPage.org/1.html"))
    {
        // perform the frame redirect here, but how?
        // so something like
        context.Response.Redirect(@"http://www.myRedirect.org");
        // but as I said that doesn't redirect as I want it to be
    }
}

それについてのアイデアはありますか?
編集: 私は例を試したので、私は持っています:

private void OnBeginRequest(object sender, EventArgs e)
{
    HttpApplication app = (HttpApplication)sender;
    HttpContext context = app.Context;

    // make a frame redirect if a specified page is called
    if (context.Request.ServerVariable["HTTP_REFERER"].Equals(@"http://www.myPage.org/1.html"))
    {
        // perform the frame redirect here, but how?
        context.Response.Write(@"<html>");
        context.Response.Write(@"<head>");
        context.Response.Write(@"</head>");
        context.Response.Write(@"<frameset rows=""100%,*"" framespacing=""0"" frameborder=""NO"" border=""0"">");
        context.Response.Write(@"<frame src=""http://www.myRedirect.org"" scrolling=""auto"">");
        context.Response.Write(@"</frameset>");
        context.Response.Write(@"<noframes>");
        context.Response.Write(@"<body>Some text...");
        context.Response.Write(@"</body>");
        context.Response.Write(@"</noframes>");
        context.Response.Write(@"</html>");
    }
}

しかし、それも正しくリダイレ​​クトされません。ブラウザにはまだリダイレクト アドレスが表示されています。他のアイデアはありますか?

編集:明らかに間違いを犯しました。上記のコードは機能し、私が望むことを行います。私のリダイレクトURLが予期しないことをしていたため、最初は機能しませんでした。

4

1 に答える 1

1

フレーム リダイレクトを実行するには、ソースをhttp://www.myRedirect.orgに設定して、単一フレームのフレームセットを含む HTML コードを送り返す必要があります。サーバーとブラウザに関する限り、リダイレクトは発生していません。HTML コードを受信しただけです。

これまで見てきたように、意志を実行するResponse.Redirectと、ブラウザは新しいページに対して新しいリクエストを作成し、ユーザーのタイトル バーに新しいアドレスを表示します。通常、ページのアドレスが実際に変更された場合に使用されますが、所有者は元の URL からもアクセスできるようにしたいと考えています。

EDIT : HTML フレーム リダイレクトのサンプル: http://en.wikipedia.org/wiki/URL_redirection#Frame_redirects

于 2010-03-23T08:49:59.260 に答える