ASP.NET MVC is a presentation framework. MVC stands for Model-View-Controller. Model gives a notion that it is related to data access. However, it is just a data abstraction for the view. It can be thought of a ViewModel.

Apart from MVC, a large ASP.NET application deals with services. It also deals with data access. We need a good project structure. In the post, we build a simple Hello world project.…

Read More

Extension method extends an existing class. In this post, we will add an extension method to HtmlHelper class. The method display error messages.

Validation

Data annotations validates user input. An example is shown below.

[Required(ErrorMessage = "Please enter name")]
public string Name { get; set; }

Controller has the ModelState object. ModelState object has the validation errors. For each user input (eg.…

Read More

There are SEO problems while using frameworks like KnockoutJS or AngularJS or ReactJS. The page loads, then javascript loads. JavaScript renders the HTML elements. Web crawlers of today do not execute the JavaScript. So, the page content is often missing or incorrect. Hence, the SEO suffers.

Update (Sep 2017): Search engines, especially Google, runs the JavaScript. SEO has improved for JavaScript frameworks.…

Read More

Sometimes, a controller action trigger a long running background process. For example, the user clicks a link in the page. Generate a word document in the background. Show the properties of the document in the subsequent page. Generation of word documents take anywhere between 3 seconds to 30 seconds. During this time, the user needs some feedback about the progress of the operation.…

Read More

Consider the following code which has a CheckBox and a submit button:

@using (Html.BeginForm())
{
    <input type="checkbox" name="Select" />
    <input type="submit" value="Submit" />
}

Submit the form. The request body has the form data with name-value pairs. If the user checks the checkbox, the form data has Select=on. If the user clears the checkbox, the form data does not contain Select.…

Read More