<%@ WebHandler Language="C#" Class="Website.robots" %> using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; using System.Data.Linq; using System.Linq.Dynamic; using System.Text; using System.Text.RegularExpressions; using System.Web; using System.Web.Security; using System.Xml; using AWMS.Core.DAL; using AWMS.Core.BLL; namespace Website { public class robots: IHttpHandler { public void ProcessRequest (HttpContext context) { sys_domain_manager _sdm = new sys_domain_manager(); var domainName = HttpContext.Current.Request.Url.Host; sys_domain _domain = _sdm.GetDomainByName(domainName); XmlDocument _sitemap = new XmlDocument(); if (!string.IsNullOrEmpty(_domain.sitemap_xml)){ _sitemap.LoadXml(_domain.sitemap_xml); _sitemap.Save(HttpContext.Current.Server.MapPath(String.Format("~/{0}.xml", _domain.url)));} context.Response.ContentType = "text/plain"; context.Response.Write("User-agent: *\n"); context.Response.Write("Allow: /\n"); context.Response.Write("Disallow: /bin/\n"); if (_domain != null){ context.Response.Write(String.Format("Sitemap: http://{0}/{0}.xml", _domain.url)); } } public bool IsReusable { get {return false;} } } }