web.config에서 <location/>
태그를 사용하여 특정 디렉토리 나 파일을 열 수 있습니다.
호스트에 의한 액세스 제어의 본질적인 방법이 있다고 나는 생각하지 않습니다.
이렇게하는 간단한 방법은 끝점이나 디렉토리를 지키는 간단한 HttpModule을 구현하는 것입니다.
using System;
using System.Net;
using System.Web;
namespace HttpLibArticleSite
{
public class GuardDogModule : IHttpModule
{
#region IHttpModule Members
public void Init(HttpApplication context)
{
context.BeginRequest += BeginRequest;
}
public void Dispose()
{
//noop
}
#endregion
private static void BeginRequest(object sender, EventArgs e)
{
HttpContext ctx = (HttpContext) sender;
if (ctx.Request.Url is not guarded) return;
if (ctx.Request.Headers["take your pick"] != what
you want)
{
ctx.Response.StatusCode = (int) HttpStatusCode.Forbidden;
ctx.Response.End();
}
}
}
}
분명히, 테스트되지 않았지만 필요한 곳으로 안내 할 것입니다. 배포 방법을 보려면 web.config system.web/httpModules 섹션을 참조하십시오.
건배.