Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:41:42+00:00 2026-06-13T08:41:42+00:00

How do I setup a scenario where one website hosted at X publishes a

  • 0

How do I setup a scenario where one website hosted at X publishes a URL that when browsed to will return purely XML.

A web page elsewhere is going to hit this URL, load the XML into objects.

So I want a url like http://www.xml.com/document.aspx?id=1

Another site will use webresponse and webrequest objects to get the response from the above page, I want the response to be good XML so I can just use the XML to populate objects.

I did get something working but the response contained all the HTML required to render the page and I actually just want XML as the response.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:41:43+00:00Added an answer on June 13, 2026 at 8:41 am

    Probably the best way to this is with a HttpHandler/ASHX file, but if you want to do it with a page it’s perfectly possible. The two key points are:

    1. Use an empty page. All you want in the markup for your ASPX is the
      <% Page … %> directive.
    2. Set the ContentType of the Response stream
      to XML – Response.ContentType = "text/xml"

    How you generate the XML itself is up to you, but if the XML represents an object graph, you can use an XmlSerializer (from the System.Xml.Serialization namespace) to write the XML directly to the Response stream for you e.g.

    using System.Xml.Serialization;
    
    // New up a serialiser, passing in the System.Type we want to serialize
    XmlSerializer serializer = new XmlSerializer(typeof(MyObject));
    
    // Set the ContentType
    Response.ContentType = "text/xml";
    
    // Serialise the object to XML and pass it to the Response stream 
    // to be returned to the client
    serialzer.Serialize(Response.Output, MyObject);
    

    If you already have the XML, then once you’ve set the ContentType, you just need to write it to the Response stream and then end and flush the stream.

    // Set the ContentType
    Response.ContentType = "text/xml";
    
    Response.Write(myXmlString);
    
    Response.Flush();
    Response.End();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a live web application that is failing in one specific scenario, and
Our current project at work is a new MVC web site that will use
I have a scenario where I need to upload a file from one web
Scenario: My general portal is hosted in IIS using ASP.NET and a login page.
I will soon be starting on a new web project that consists of 2
I'm trying to setup my table so that the user can select one item
In the default TFS setup there are three work item types: scenario, task and
Here's my scenario. I've got SharePoint 2010 running on one server, with an SQL
hey guys, here's a simple scenario NServiceBus Client/Server setup. The Message is a custom
I recently setup a WCF service using Visual Studio 2010. The service is hosted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.