1

ASP.Net を使用して、HttpContext.Current.RewritePath を使用して別のドメインに書き換えることは可能ですか? 例えば。

HttpContext.Current.RewritePath("http://www.otherdomain.com");

これを試すと、次の例外が発生します。

「http://www.otherdomain.com」は有効な仮想パスではありません

4

1 に答える 1

1

HttpContext.Current.RewritePathサーバー側でのurlの書き換えです。

これは、URL を要求する場合、次を使用し/productsて asp.net に rednder を指示できることを意味します。/Products.aspx

if( HttpContext.Current.Request.RawUrl == "/products")
     HttpContext.Current.RewritePath("/Products.aspx");

ユーザーを別のドメインに送信する場合は、次のことを行う必要があります。

HttpContext.Current.Response.Redirect("http://www.otherdomain.com/page");

于 2012-09-27T07:20:58.563 に答える