You can write a custom type binding and register it in the application launch event handler in global.asax:
protected void Application_Start()
{
ModelBinders.Binders.Add(typeof(XDocument), new YourXDocumentBinder());
}
The MVC pipeline is automatically called by the binder when it encounters an action with an XDocument argument.
The binder implementation will look something like this:
public class YourXDocumentBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
}
}
m0sa source
share