ASP.NET Web API has an oAuth2 server. There is an endpoint, /token. Posting to the token endpoint with login credentials gives an access token. For authorising the user, pass the access token to all other endpoints exposed by the API.

Role based security restricts access to various parts of the API based on the user’s role. For example, there is more API access for admin users.…

Read More

ASP.NET Identity Framework 2.0 is integrated with EntityFramework. The entity classes available are Users, Roles, Claims and Logins. The Identity database can be any store – SQL Server, MySQL or Oracle. This article provides guidance on how to integrate ASP.NET Identity 2.0 with a MySQL database.

SQL scripts for MySQL

MySQL has naming conventions which are very different from SQL Server.…

Read More

Validation in ASP.NET MVC is done by decorating model properties with attributes. There are some built-in validation attributes. For example, Required attribute ensures that there exists a value for the property. We can write custom validation attributes as well. In this post, we build a UrlValid attribute. When the user enters an URL in a TextBox, the UrlValid attribute verifies if the URL is active.…

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