<%@ WebHandler Language="C#" Class="MyNamespace.robotshandler" %> using System; using System.Web; namespace MyNamespace { public class robotshandler: IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("User-agent: *\n"); if (context.Request.ServerVariables["Https"]=="off"){ // HTTP context.Response.Write("Allow: /\n"); context.Response.Write("Disallow: /MyDisallowedDirectory/\n"); } else { // HTTPS context.Response.Write("Disallow: /"); } } public bool IsReusable { get {return false;} } } }