473,497 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IHttpHandler

Hello,

I am using an ASP.NET 3.5 SP1 and a while ago I created an
IHttpHandler that transforms a Sitemap XML file to a compatible Google
Sitemap (https://www.google.com/webmasters/tools/docs/en/
protocol.html#sitemapXMLExample) XML file using a XSD file.

Now I need to do something similar but I need to create the XML file
from scratch using data that I am getting from an SQL database using
linq.

My problem is how to create the XML file into the stream ... I suppose
this is still the way to do it, right?

My code was done using ASP.NET 2.0.

Public Class SiteMap : Implements IHttpHandler

Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return False
End Get
End Property

Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest

Dim app As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly

Dim str As Stream = app.GetManifestResourceStream("SiteMap.xsl")

Dim xmlrSiteMap As Xml.XmlReader = Xml.XmlReader.Create(str)

Dim xslGoogle As XslCompiledTransform = New XslCompiledTransform
xslGoogle.Load(xmlrSiteMap)

Dim xpathGoogle As System.Xml.XPath.XPathDocument = New
System.Xml.XPath.XPathDocument(HttpContext.Current .Server.MapPath("SiteMap.xml")))

Dim msGoogle As System.IO.Stream = New System.IO.MemoryStream

Dim googleXslArguments As XsltArgumentList = New
XsltArgumentList
googleXslArguments.AddParam("WebSite.Url", "", "http://" &
ConfigurationManager.AppSettings("WebSite.Url") & "/")

xslGoogle.Transform(xpathGoogle, googleXslArguments, msGoogle)

msGoogle.Flush()
msGoogle.Position = 0

Dim srGoogle As System.IO.StreamReader = New
System.IO.StreamReader(msGoogle)

context.Response.Clear()
context.Response.ContentType = "text/xml; charset=utf-8"
context.Response.Write(srGoogle.ReadToEnd)
context.Response.End()

End Sub ' ProcessRequest

End Class ' SiteMap

Thanks,
Miguel
Oct 1 '08 #1
0 1185

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1446
by: lapin | last post by:
I'm trying to get access to session variables from an IHttpHandler class. In several places I've seen the solution posted as in this message: >If you define your own custom HttpHandler, you need...
1
3061
by: lapin | last post by:
I'm trying to get access to session variables from an IHttpHandler class. In several places I've seen the solution posted as in this message: >If you define your own custom HttpHandler, you...
13
4280
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
5
1992
by: vimakefile | last post by:
I'd like to have the concept of a Page (different code-behind file for each url, session state, etc.) but be able to specify my own custom HTTP payload. (I don't want to use any Asp.Net forms,...
0
1048
by: Stu | last post by:
Hi, I am trying to write a basic httphandler to 'fake' that pages actually exist. I have copied the code below from various sites - but the line 'Implements IHttpHandler' reports an error "type...
2
8025
by: bryan | last post by:
I can't find much info on what makes an instance of the handler reusable. If it maintains no internal state, I would assume that it is safe to be reusable - correct? I have one that grabs a value...
24
2723
by: John Rivers | last post by:
ASPX which means ASPX pages, the code-behind concept, User Controls, Web Controls etc. is very poorly designed and makes it extremely hard to develop professional quality web applications. ASPX...
1
1271
by: David Thielen | last post by:
Hi; I just wrote my first IHttpHandler and am having a problem. If the content type is "text/html" then the below code works fine. But if it's "text/plain" then my browser gets: The XML page...
1
4293
by: Aartware | last post by:
I've read all the items about the IHttpHandler and the session-object and I see nothing wrong with my code, but still I have no session object. This is my code: Imports System Imports...
0
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1405
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
286
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.