2

Is it possible to send POX (plain old xml) into an action and have that action perform model binding to an object for you. Have seen this done with JSON but dont see anyone doing this with xml.

4 Answers 4

2

Looking at doing a similar thing, but with JSON. I think you could also use a ActionFilterAttribute for this purpose. An example is shown here.

Sign up to request clarification or add additional context in comments.

Comments

1

You can achieve this by creating your own model binders.

you can get idea from the following links.

http://odetocode.com/blogs/scott/archive/2009/04/27/6-tips-for-asp-net-mvc-model-binding.aspx

http://odetocode.com/blogs/scott/archive/2009/05/05/iterating-on-an-asp-net-mvc-model-binder.aspx

Comments

1

Phil Haack did this for JSON using a JSON Value Provider. Inspired by that and starting with his source code I created an XML Value Provider Factory.

You can download the source for my XML Value Provider here.

Comments

0

I have found a cleaner way to do this than Igor's suggestion. Phil Haack has an article ( Sending JSON to an ASP.NET MVC Action Method Argument) that uses a JsonValueProviderFactory from MVC futures. So I think all I need to do is create a XmlValueProviderFactory which will allow default model binding to occur. Will update when I get this to work

1 Comment

I had the same idea. It took me a while to get it working though. I've included a link to what I came up with in my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.