.Net MVC ApiController 和普通 Controller 的区别是什么?

「已注销」 2014-07-08 06:55:45
1:两者之间有什么本质区别,普通controller是否也能完全实现APIconroller下的功能。反过来呢?
2:普通Controller可以有对应的拦截器接口IAuthorizationFilter,IActionFilter等内置的Filter,那么在ApiController中是否依然能用?
3:如果需要在ApiController中使用拦截器,应该怎么做?
Note:
在ApiController中可以通过继承System.Web.Http.Filters.ActionFilterAttribute重写其OnActionExecuting来对action执行前进行处理。在普通controller中也可以通过实现IActionFilter来实现。请问他们之间有什么本质区别?
最后:如果需要对普通Controller和apiController都做过滤或者验证,你有什么好的建议?
...全文
6324 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2014-07-08
  • 打赏
  • 举报
回复
引用 1 楼 caozhy 的回复:
继承的基类不同,花10分钟看下各自的源代码所有问题全搞懂了。
技术能力不行啊。不是很看得懂
threenewbee 2014-07-08
  • 打赏
  • 举报
回复
继承的基类不同,花10分钟看下各自的源代码所有问题全搞懂了。
Book Description Develop next-generation web applications with ASP.NET MVC Go deep into the architecture and features of ASP.NET MVC 5, and learn how to build web applications that work well on both the desktop and mobile devices. Web development expert Dino Esposito takes you through the web framework’s Model-View-Controller (MVC) design model, and covers the tools you need to cleanly separate business logic from the user interface. If you’re an experienced web developer new to ASP.NET MVC, this practical guide will get you going. Discover how to: Build web applications that are easy to test and maintain Dive into the functions of controllers—the heart of an MVC site Explore the structure and behavior of a view engine Process a variety of input data using a custom model binder Automate the writing of input forms, and streamline validation Design websites for mobile devices, localization, and error handling Provide security by implementing a membership system Inject script code into your site using JavaScript and jQuery Use Responsive Web Design to make sites mobile-friendly Table of Contents Part I: ASP.NET MVC fundamentals Chapter 1. ASP.NET MVC controllers Chapter 2. ASP.NET MVC views Chapter 3. The model-binding architecture Chapter 4. Input forms Part II: ASP.NET MVC software design Chapter 5. Aspects of ASP.NET MVC applications Chapter 6. Securing your application Chapter 7. Design considerations for ASP.NET MVC controllers Chapter 8. Customizing ASP.NET MVC controllers Chapter 9. Testing and testability in ASP.NET MVC Chapter 10. An executive guide to Web API Part III: Mobile clients Chapter 11. Effective JavaScript Chapter 12. Making websites mobile-friendly Chapter 13. Building sites for multiple devices Book Details Paperback: 516 pages Publisher: Microsoft Press; 3rd Edition (February 2014) Language: English ISBN-10: 0735680949 ISBN-13: 978-0735680944

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧