<%@ 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"; if (context.Request.ServerVariables["Https"]=="off"){ // HTTP using(System.IO.StreamReader fs = System.IO.File.OpenText(HttpContext.Current.Server.MapPath("/robots-HTTP.txt"))) { string exclusions = fs.ReadToEnd(); context.Response.Write(exclusions); } } else { // HTTPS context.Response.Write("User-agent: *\n"); context.Response.Write("Disallow: /"); } } public bool IsReusable { get {return false;} } } }