0

Can an IIS 7 module retrieve the server in an OnAuthenticateRequest hook or an OnPostAuthenticateRequest hook?

By "server" I mean the server that the IIS authenticated against (even if it's localhost, for example in the case of windows authentication)

4

1 に答える 1

2

イベント デリゲートとして追加するメソッドでは、次のようなことができます。

private void onAuthenticateRequest(object sender, EventArgs e) {
  var application = (HttpApplication) sender;
  HttpContext context = application.Context;

  string address = context.Request.ServerVariables["LOCAL_ADDR"];
}

これにより、現在ユーザーの要求を処理しているサーバーの IP アドレスが得られます。サーバーが必要な場合は、代わりにSERVER_NAMEまたはを使用できます。HTTP_HOST

于 2010-11-23T19:50:36.980 に答える