up vote 1 down vote favorite
share [fb]

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

link|improve this question
feedback

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.

link|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. – Rick Dec 17 '10 at 14:06
feedback

Your Answer

 
or
required, but never shown

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