Invalid RSS created by ASP.NET page

H

henrybranson

I'm trying to create an RSS feed that is written dynamically by an
ASP.NET page. I know there are several ways to do it, but the quickest
for me was to follow the Scott Mitchell tutorial at
http://msdn.microsoft.com/library/d...n-us/dnaspp/html/aspnet-createrssw-aspnet.asp.

I think the problem is that the <@ page > directive at the top of the
ASP.NET page creates a blank first line in the outputted XML. This
blank line makes the RSS feed invalid, and News Readers such as
NewzCrawler won't parse it.

Is it possible to output xml (or anything for that matter) from an
ASP.NET page with the @ Page directive in without leaving the first
line blank?

Many thanks

Henry
 
B

Brock Allen

If the <%@Page %> is being emitted to the client, then it sounds like the
page isn't being processed on the server normally. Perhaps ASP.NET isn't
propery registered on the server?
 
H

henrybranson

Thanks Brock

The <%@Page %> isn't being output to the browser, but line one of the
XML output to the browser is blank, because (i'm guessing) this is
where the directive sits in the .aspx before it delivers its output.
The problem is getting the output from the aspx file to begin on line
one not line 2. Any ideas?

Henry
 
P

Patrice

IMO this is because it outputs the line feed that follows the directive.

The first solution I see would be then to have the first tag, just after the
page directive (on the same line)...

Patrice
 
L

Lance R.

I'm trying to create an RSS feed that is written dynamically by an
page. I know there are several ways to do it, but the quickest
for me was to
follow the Scott Mitchell tutorial at
http://msdn.microsoft.com/library/d...n-us/dnaspp/html/aspnet-createrssw-aspnet.asp.

I think the problem is that the <@ page > directive at the top of the
ASP.NET page creates a blank first line in the outputted XML. This
blank line makes the RSS feed invalid, and News Readers such as
NewzCrawler won't parse it.

Is it possible to output xml (or anything for that matter) from an
ASP.NET page with the @ Page directive in without leaving the first
line blank?

Just use Response.Clear first, ie:

Response.Clear();
Response.ContentType = "text/xml";
Response.Write(rss1.RSSData); //rss1 is the ipworks RSS control in this sample Response.End();

Regards,
Lance R.
/n software
http://www.nsoftware.com/

-
 
H

henrybranson

Patrice, Lance

Thank you both for your ideas, both of which I think would work
depending on how I was doing it. However, sometimes the simplest ideas
are best, and Patrice was spot on. I moved my Repeater object to line
one, like so:

<%@ Page Language="vb" ContentType="text/xml" AutoEventWireup="false"
Codebehind="index.aspx.vb" Inherits="rss.index" %><asp:Repeater
id="RssRepeater" runat="server"><HeaderTemplate><?xml version="1.0"
encoding="UTF-8" ?>

and hey presto, the output starts on line one. So simple, why didn't I
think of it myself?

Thanks guys.

Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top