目前在做的项目里要用到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 …
ASP.NET The model in MVC3 is self-validating, which is via the System.ComponentModel.DataAnnotations namespace from NET4. All we need to do is add the corresponding Attributes to the attributes of the Model class, and then the MVC3 framework will do the validation for us. I will use the login that comes with the MVC3 project template as an example to explain the validation of the model. 1. Enable Client Validation Client-side validation is mainly to improve the user experience, and the validation is completed without the web page being brushed back. The first step is to enable client validation in web.config, which is already available in the template project that comes with MVC3