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