MVC newbie here:
I’ve more or less worked out the page navigation aspect of MVC. But let’s say I don’t want to navigate to a View, but rather I want to get a response out of the web site, e.g. by sending a request to http://mysite.com/Services/GetFoo/123 I want to make a database request to select a Foo object with ID 123 and return it serialized as XML.
How do you do that?
I would write a custom action result:
and then in my controller:
And if this
return new XmlResult(foo);feels ugly to your eyes, you could have an extension method:and then: