473,603 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

response object assistance with returning xml.

I have a page which upon opening gets information from a database, the field
it returns has structured xml stored in it.

private void Page_Load(objec t sender, System.EventArg s e)

{

if (!IsPostBack) {

GetRecordFromSe rver(this.Reque st.QueryString[0].ToString());

}

}

private void GetRecordFromSe rver(string searchID) {
DataSet ds = dbAuditLog.GetE ntry(new Guid(searchID)) ;

DataTable dt = ds.Tables[0];
Response.Conten tType = "Text/XML";

Response.Output .Write(dt.Rows[0]["XMLText"].ToString());
}

The problem I am having is that the resulting page does not quite display
properly, it always seems to add the following to the end of the xml, I just
want the xml from my field to be streamed to the response, and that is all,
can anyone help ?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>dbaudmes s</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form name="Form1" method="post"
action="dbaudme ss.aspx?searchI D=551687bf-07db-4199-8be6-2a2682d6e49f"
id="Form1">
<input type="hidden" name="__VIEWSTA TE"
value="dDwtNjU0 MzcyMTk1Ozs+/NB5NnLZUiFzN88M 2i+3c1vA1l0=" />

</form>
</body>
</HTML>
Nov 19 '05 #1
3 1236
You need to rip everything (well almost everything) out of your aspx file;

For example;

<%@ Page language="c#" Codebehind="Dis playXML.aspx.cs "
AutoEventWireup ="false" Inherits="YourN amespace.Displa yXML" %>

"Martin Dew" wrote:
I have a page which upon opening gets information from a database, the field
it returns has structured xml stored in it.

private void Page_Load(objec t sender, System.EventArg s e)

{

if (!IsPostBack) {

GetRecordFromSe rver(this.Reque st.QueryString[0].ToString());

}

}

private void GetRecordFromSe rver(string searchID) {
DataSet ds = dbAuditLog.GetE ntry(new Guid(searchID)) ;

DataTable dt = ds.Tables[0];
Response.Conten tType = "Text/XML";

Response.Output .Write(dt.Rows[0]["XMLText"].ToString());
}

The problem I am having is that the resulting page does not quite display
properly, it always seems to add the following to the end of the xml, I just
want the xml from my field to be streamed to the response, and that is all,
can anyone help ?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>dbaudmes s</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form name="Form1" method="post"
action="dbaudme ss.aspx?searchI D=551687bf-07db-4199-8be6-2a2682d6e49f"
id="Form1">
<input type="hidden" name="__VIEWSTA TE"
value="dDwtNjU0 MzcyMTk1Ozs+/NB5NnLZUiFzN88M 2i+3c1vA1l0=" />

</form>
</body>
</HTML>

Nov 19 '05 #2
I also have an application that returns Xml to the user. I actually use
"text/plain" as the content type, but that's because the user will likely
need to copy and paste the Xml and if I use "text/xml" then IE hides the Xml
tags and only displays the text.

But anyway, try this before you write to the stream:

HttpContext context = HttpContext.Cur rent;
context.Respons e.Clear();
context.Respons e.ContentType = "text/xml";

Or more simply :
Response.Clear( );
Response.Conten tType = "text/xml";

The first is what I have in my code and both snippets should be the same,
but it's just what I wrote at the time, I don't remember why I chose that
method.

Regards,
Mark

"Martin Dew" wrote:
I have a page which upon opening gets information from a database, the field
it returns has structured xml stored in it.

private void Page_Load(objec t sender, System.EventArg s e)

{

if (!IsPostBack) {

GetRecordFromSe rver(this.Reque st.QueryString[0].ToString());

}

}

private void GetRecordFromSe rver(string searchID) {
DataSet ds = dbAuditLog.GetE ntry(new Guid(searchID)) ;

DataTable dt = ds.Tables[0];
Response.Conten tType = "Text/XML";

Response.Output .Write(dt.Rows[0]["XMLText"].ToString());
}

The problem I am having is that the resulting page does not quite display
properly, it always seems to add the following to the end of the xml, I just
want the xml from my field to be streamed to the response, and that is all,
can anyone help ?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>dbaudmes s</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form name="Form1" method="post"
action="dbaudme ss.aspx?searchI D=551687bf-07db-4199-8be6-2a2682d6e49f"
id="Form1">
<input type="hidden" name="__VIEWSTA TE"
value="dDwtNjU0 MzcyMTk1Ozs+/NB5NnLZUiFzN88M 2i+3c1vA1l0=" />

</form>
</body>
</HTML>

Nov 19 '05 #3
Hello Martin,

Make sure you do a Response.End() after the XML is written out. This stops
the processing of the current response.

--
Matt Berther
http://www.mattberther.com
I have a page which upon opening gets information from a database, the
field it returns has structured xml stored in it.

private void Page_Load(objec t sender, System.EventArg s e)

{

if (!IsPostBack) {

GetRecordFromSe rver(this.Reque st.QueryString[0].ToString());

}

}

private void GetRecordFromSe rver(string searchID) {

DataSet ds = dbAuditLog.GetE ntry(new Guid(searchID)) ;

DataTable dt = ds.Tables[0];

Response.Conten tType = "Text/XML";

Response.Output .Write(dt.Rows[0]["XMLText"].ToString());

}

The problem I am having is that the resulting page does not quite
display properly, it always seems to add the following to the end of
the xml, I just want the xml from my field to be streamed to the
response, and that is all, can anyone help ?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>dbaudmes s</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form name="Form1" method="post"
action="dbaudme ss.aspx?searchI D=551687bf-07db-4199-8be6-2a2682d6e49f"
id="Form1">
<input type="hidden" name="__VIEWSTA TE"
value="dDwtNjU0 MzcyMTk1Ozs+/NB5NnLZUiFzN88M 2i+3c1vA1l0=" />
</form>
</body>
</HTML>


Nov 19 '05 #4

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

Similar topics

35
34411
by: Eitan | last post by:
Hello, How can I write a line (with carriage return + line feed) to the client ? response.write("abcd"), continue the last line, and doesn't put cr+lf. response.writeLn is illegal syntax... Thank :)
6
4312
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx serves two purposes, 1. it contains a tab strip with response.redirects to navigate to the other pages; 2. I authenticate the user by check to see if a cookie exists, if it doesn't I redirect to a login screen.
0
3539
by: iKiLL | last post by:
Hi All Code Below for this problem ERROR: "An existing connection was forcibly closed by the remote host"
0
7996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8415
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8405
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8273
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6735
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5878
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3951
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2430
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 we have to send another system

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.