ASP.NET MVC里面我们要自定义ActionFilter的时候会发现有4个方法可以override:OnActionExecuting,OnActionExecuted,OnResultExecuting,OnResultExecuted。他们分别在什么时候执行一直是困扰人类的一个问题。我代表人类做了一个简单的实验: 首先自定义一个ActionFilter,每个方法执行的时候都在VS的OUTPUT窗口输出信息: public class TestActionFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { Debug.WriteLine("OnActionExecuting"); …
目前在做的项目里要用到RESTful Service,一开始是用WCF WebHttpBinding撸的,但我知道WebAPI才是最适合的,正好现在VS2013 RTM了,Web API 2也跟着ASP.NET MVC5一起发布了,于是今天就把Service用Web API 2重写了一下。
我选择Web API的一个重要原因就是因为可以自动生成文档,省去了开发人猿不少宝贵的时间。以前在用Web API第一代的时候,自动生成帮助文档的功能默认是不完整的,现在到了Web API 2,这个功能已经通过NuGet包的形式很好的整合到了一起。我们来看一下吧!
首先,用VS2013创建的Web API 2项目会默认带有Microsoft ASP.NET Web API Help Page的包。如果没有,就需要手动去NuGet上安装。
在安装了这个包以后,你的Web API项目目录里会多一个 …
First of all, I don't recommend storing images in the database, especially in a web project. Because file systems can provide static file access and get many benefits such as performance. Storing images in the database has certain limits.
But if you must store images into SQL Server, here's how to do it.
SQL
Image files are in fact, binary data. SQL Server provides us the image type for …