阅读背景:

使用相同的控件通过Web API MVC4返回JSON / XML / HTML

来源:互联网 

I am guessing it has been asked before but I did not see it and thought maybe I am missing something fundamental. My question is why can't I have one API controller that bases the format of result on the accepted content format(i.e. application/json)? Maybe I am being lazy - but I rather do something like if html is the expected result format than let me return a view, if json is the accept format than I can return JSOn -etc... If I have two namespaces, then that is also two methods I have to maintain - when the only difference is the media format. I am guessing it has been asked before but I di




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: