I have been working on the next version of my blog recently, and one of the updates is upgrading Entity Framework to version 5.0. When I initially set up the blog, I used EF4 that came with VS2010. The upgrade process from version 4.0 has to be done manually; using NuGet for the upgrade can only automatically update to versions 4.1 and above. Yesterday, I worked on it for a long time, and finally got the website up and running. Here's what I learned from the experience.
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
最近在研究Razor和MVC,打算逐步把博客用Razor重写一边。今天一上手就碰到个蛋碎的问题。不管是在MVC应用程序,还是传统的WebForm项目中添加Razor页(既.cshtml类型的页面),就会导致自定义的Membership Provider失效。如果去掉Membership的配置则一切正常。 具体问题表现在有两个地方报错: 1. 运行时报错:Parser Error Message: Default Membership Provider could not be found. 2. 编译时报错:Error 58 The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an …