Response.Write inserting extra

S

Steve

Hello,
I'm creating an .aspx page that gets an XML document (as a string) from a
server via .NET remoting and returns it in the Response.Write method.
I'm saving the document to a file before I return it from the server and it
looks good, well formed and all. But, when I use Explorer to hit the .aspx
page, it returns the document but sticks this in the document some place:
<SN>96620150</SN>
<< The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.


Cannot have a DOCTYPE declaration outside of a prolog. Error processing
resource
'http://localhost/GetSpatialSearch/MySpatialSearch.aspx?layerName=centroid&s
n=98676052&format=xml'. Line 2, Position 11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
----------^
SPAN class="t">SN>96620066</SN>

The above text shows one of the elements (the <SN> element), then the error
text, then another element.

I'm doing a
Response.ContentType = "Text/XML";

prior to writing out to the Response object.
Anybody know how I can get rid of this or is it just and Internet Explorer
thing?

Thanks
Steve
 
A

ashelley

Hello,
I'm creating an .aspx page that gets an XML document (as a string) from a
server via .NET remoting and returns it in the Response.Write method.
I'm saving the document to a file before I return it from the server and it
looks good, well formed and all. But, when I use Explorer to hit the .aspx
page, it returns the document but sticks this in the document some place:
<SN>96620150</SN>
<< The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.


Cannot have a DOCTYPE declaration outside of a prolog. Error processing
resource
'http://localhost/GetSpatialSearch/MySpatialSearch.aspx?layerName=centroid&s
n=98676052&format=xml'. Line 2, Position 11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
----------^
SPAN class="t">SN>96620066</SN>

The above text shows one of the elements (the <SN> element), then the error
text, then another element.

I'm doing a
Response.ContentType = "Text/XML";

prior to writing out to the Response object.
Anybody know how I can get rid of this or is it just and Internet Explorer
thing?

Thanks
Steve

Sounds like something is getting put into the response stream before
the xml document. Read through the code to find out why there are
elements being output before the actual XML document.

I successfully use this code to output an xml document to the page:

Response.Buffer = true;
Response.ContentType = "text/xml";
xReturn.LoadXml(sXML); // xreturn is an xmldocument.
xReturn.WriteTo(new System.Xml.XmlTextWriter(Response.Output));
Response.Flush();
Response.End();

Also, have you tested the XSL and verified it works?

-Adam
 
H

Hans Kesting

Steve said:
Hello,
I'm creating an .aspx page that gets an XML document (as a string) from a
server via .NET remoting and returns it in the Response.Write method.
I'm saving the document to a file before I return it from the server and it
looks good, well formed and all. But, when I use Explorer to hit the .aspx
page, it returns the document but sticks this in the document some place:
<SN>96620150</SN>
<< The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.


Cannot have a DOCTYPE declaration outside of a prolog. Error processing
resource
'http://localhost/GetSpatialSearch/MySpatialSearch.aspx?layerName=centroid&s
n=98676052&format=xml'. Line 2, Position 11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
----------^
SPAN class="t">SN>96620066</SN>

The above text shows one of the elements (the <SN> element), then the error
text, then another element.

I'm doing a
Response.ContentType = "Text/XML";

prior to writing out to the Response object.
Anybody know how I can get rid of this or is it just and Internet Explorer
thing?

Thanks
Steve

Did you remove everything (except the <%@ Page %> directive) from the aspx
page? It sound as if that is sent along with the xml document.

The file you write out, does it look good to your eyes, or is it also possible
to open it in IE (use .xml extension)?
What does "View Source" in IE on the (partially) displayed aspx look like?

Hans Kesting
 
S

Steve

Okay, there was something in the .aspx page. I totally forgot about that. I
just removed everything except the @Page directive and all seems well now.
Thanks very much for your help Hans.

Steve
 

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,816
Messages
2,569,712
Members
45,499
Latest member
BreannaWhi

Latest Threads

Top