Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Open Google blogger uses XML templates for blogs. I want to implement same kind functionality in my asp.net mvc and asp.net applications.

We can use master pages and themes in asp.net applications but I need to use XML templates same like Google Blogger uses.

This question is in continuation to my previous discussion : link text

share|improve this question

closed as unclear what you're asking by gnat, MichaelT, david.pfx, Bart van Ingen Schenau, MainMa May 18 at 20:11

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

1 Answer

ASP.NET MVC does not impose restrictions on your responses. Your templates can be any form of XML, XHTML, HTML, JSON, etc. that you need. The question then comes how do you want to form the XML? You have two options:

  • System.Xml.Serialization.XmlSerializer--XML generated automatically from model, convenient but limited control
  • Using the same template aspcx approach you would for HTML files--most control, slightly less convenient

My guess is that you will want to use the second option. The second option guarantees the output of your XML will be able to comply with whatever standard you want. In that case, your controller has one responsibility other than responding with return View(model);. That is setting the response content type correctly. The response content type should be text/xml (mime type for XML documents).

Your template master will handle all the header information (xml declarations, namespace declarations, etc.), and the <asp:ContentPlaceHolder ID="MainContent" runat="server" /> would call your specific view. Do note that every template needs to be valid XML for this to work. You'll have to escape certain embedded content to make sure of it.

share|improve this answer
    
Thanks for marvelous answer. I will be thanksful, if you provide some code-snippets, if you can. I want to vote your asnwer, but can't because I need reputation points to vote. –  Gaurav Kumar Arora Dec 17 '10 at 14:06
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.