質問

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 が予期しない動作をしていたため、最初は機能しませんでした。

役に立ちましたか?

解決

あなたがHTMLコード含むAを返送する必要がこの フレームリダイレクトを実行するには http://www.myRedirect.orgするにそれのソースが設定された単一のフレームとフレームセット、。サーバとブラウザに関する限り何のリダイレクトは起こっていない - それはほんの一部のHTMLコードを受けています。

、あなたが観察してきたように、ユーザーにタイトルバーに新しいアドレスを示す、新しいページへの新鮮な新しい要求を行うために、ブラウザの原因となりますResponse.Redirectを行います。これは、通常、ページが実際にそのアドレスを変更しますが、所有者はまだそれは同様に、元のURLから到達したいときに使用します。

編集:HTMLフレームリダイレクトサンプル:ます。http:// EN .wikipedia.org /ウィキ/ URL_redirection#Frame_redirectsする

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top