<%@ WebHandler Language="C#" Class="MyNamespace.robotshandler" %> using System; using System.Web; using System.Data; using FDFC; using FDWeb; namespace MyNamespace { public class robotshandler: IHttpHandler { public int Id; public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; Id = GetDealerId(); if (Id == 1 || Id == 53 || Id == 54 || Id == 56 || Id == 57 || Id == 31144 || Id == 31142) { context.Response.Write("User-agent: *"); context.Response.Write(Environment.NewLine); context.Response.Write("Disallow: /"); context.Response.Write(Environment.NewLine); } else { context.Response.Write("Sitemap: "); context.Response.Write(System.Web.HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd(new Char[] { '/' }) + "/" + "sitemap" + Id + ".xml" ); context.Response.Write(Environment.NewLine); context.Response.Write(Environment.NewLine); context.Response.Write("User-agent: *"); context.Response.Write(Environment.NewLine); context.Response.Write("Disallow: /ContactUs.aspx*$"); context.Response.Write(Environment.NewLine); } } public bool IsReusable { get {return false;} } public int GetDealerId() { try { DataSet myDS = new DataSet(); string file; int id; //file = HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd(new Char[] { '/' }) + "/" + @"/Current/DealerConfig/Dealer.config"); //file = @"/Current/DealerConfig/Dealer.config"; file = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath + @"\Current\DealerConfig\Dealer.config"); //file = HttpContext.Current.Request.ApplicationPath + @"\Current\DealerConfig\Dealer.config"; file = file; myDS.ReadXml(file); id = FDFC.Utilities.NullSafeInt32(myDS.Tables[0].Rows[0]["Id"], 1); return id; } catch { return 0; } } } }