Uploading files in ASP.Net MVC



Uploading files in a web application is a common task that every web developer has done at least a couple of times but implementing this task in ASP.Net MVC is kind of different than other web frameworks.
In this article, we’re going to see how we can upload files to the server in ASP.net MVC framework and you’ll see how much easier this is can be done because almost all the nasty work is already done for us.

Single file upload

First of all we need a HTTP GET action that will render the upload file Form. The view will be very simple, something like this: Continue reading


Validation Attributes in ASP.Net MVC


In this article I’m going to show you how to use some of the validation attributes provided by the asp.net MVC framework that can be used to validate your models and you’ll see by the end of this article how easy to use them and especially how much time you’re going to save comparing with the explicit model validation way.
Before we start, you need to know that all of these attributes are defined in the System.ComponentModel.DataAnnotations namespace, so make sure to import it before starting to use any validation attribute Continue reading

Creating a custom HTML Helper in ASP.Net MVC

Asp.net MVC has many built-in Razor HTML Helpers that you can use them to create your views. By using these Helpers, you’re going to reduce the time you normally need to create a view by using HTML from scratch.

What’s an HTML Helper

An HTML helper is just a method that returns a string that contains a valid HTML, for example it can contain a valid password input HTML tag.
There is many built-in HTML hlepers in ASP.Net MVC like (not a complete list): Continue reading