1 namespace MusicStore.List
2 {
3 using System;
4 using System.Web;
5 using System.Web.Services;
6 using System.Xml;
7 using System.Xml.Xsl;
8 using MusicStore.Utility;
9
10 /// <summary>
11 /// $codebehindclassname$ 的摘要说明
12 /// </summary>
13 [WebService(Namespace = "http://tempuri.org/")]
14 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
15 public class Default : IHttpHandler
16 {
17
18 public void ProcessRequest(HttpContext context)
19 {
20 string xmlFileName = "Genres.xml";
21 string xmlPath = context.Server.MapPath(xmlFileName);
22
23 if (!context.Request.IsSpiderRequest())
24 {
25 context.Response.Redirect(xmlFileName);
26 return;
27 }
28
29 string xslPath = context.Server.MapPath("Genres.xslt");
30
31 XslCompiledTransform xslt = new XslCompiledTransform();
32
33 XsltSettings xsltSettings = new XsltSettings();
34 xsltSettings.EnableDocumentFunction = true;
35 xsltSettings.EnableScript = true;// 转换时允许执行xslt中的脚本
36
37 xslt.Load(xslPath, xsltSettings, new XmlUrlResolver());
38 xslt.Transform(xmlPath, null, context.Response.OutputStream);
39 }
40
41 public bool IsReusable
42 {
43 get
44 {
45 return false;
46 }
47 }
48 }
49 }