Securing ASP.NET Web API using Custom Token Based AuthenticationProviding a security to the Web API’s is important so that we can restrict the users to access to it. We can provide the security in two different ways: Basic authentication. Token based authentication.In this blog, we will discuss how we can implement token based authentication. Below diagram shows the control flow of token based authentication.Fig: Token based authentication for Web API’s.How token based authentication...
Read More
When you are working with certain projects which involves the Customer records, you might need to track of each and every addition/change made to system along with who create, modify and delete the records. Here I am going to show you how to implement the Audit Trail using Entity Framework in ASP.NET. Entity Framework keeps track of entity objects when we have modified them. Here I am going to use the ‘ObjectStateManager’ which is EF’s caching management object to access t...
Read More
What does it mean?Asynchronous actions allow developers to handle more concurrent requests and can be implemented using async / await keywords.Asynchronous actions are useful in scenarios where we are performing some network operation such as calling a remote service, webapi etc.What are the Benefits?1) It can make application to handle more users. 2) It can process multiple I/O bound methods in parallel3) It can make UI interface more responsive to the user4) It can perform compl...
Read More
ELMAH(Error Logging Modules And Handlers)What is ELMAH?ELMAH (Error Logging Modules and Handlers) is a series of HTTP modules and an HTTP handler that may be added to your ASP.NET web applications for the purpose of tracking unhandled exceptions. ELMAH provides access to view these errors by way of a web console, email notifications. It is open-source error logging system. ELAMH displays a list of errors and the details of a specific error from a web page.Exception log Files Storage: E...
Read More
Unit Testing – ExplainedA process which involves writing code to verify a system at a lower and more granular level is known as Unit Testing. Unit Testing gives us the ability to verify that our functions/methods work as expected. It is used by programmers for programmers.Unit tests are written to ensure that code performs as per the programmer’s expectation. They are generally focused at a lower level than other testing, making sure that the underlying feature work as expected. By e...
Read More
View Engine is responsible for rendering the view into html form to the browser.ASP.NET MVC includes two different view engines, the newer Razor View Engine and the older Web Forms View Engine. What is Razor?The Razor view was introduced with ASP.NET MVC 3 and is the default view engine moving forward.Razor provides a streamlined syntax for expressing views that minimizes the amount of syntax and extra characters. It effectively gets out of your way and puts as little syntax as possible between ...
Read More
ASP.NET MVC provides us two options ViewData and ViewBag for passing data from controller to view.ViewData and ViewBag are almost similar. Passing data with ViewBag.The ViewBag feature allows us to define arbitrary properties on a dynamic object and access them in a view.The dynamic object is accessed through the Controller.ViewBag property.Let us see how the ViewBag works through a small example.After creating a new MVC application in the HomeController Write the following code in the Inde...
Read More
There are multiple Validation attributes available in MVC. Validation attributes comes from System.ComponentModel.DataAnnotations.Available validation attributes are-System.ComponentModel.DataAnnotations.CompareAttributeSystem.ComponentModel.DataAnnotations.CustomValidationAttributeSystem.ComponentModel.DataAnnotations.DatatypeAttributeSystem.ComponentModel.DataAnnotations.MaxLengthAttribueSystem.ComponentModel.DataAnnotations.MinLengthAttributeSystem.ComponentModel.DataAnnotations.RangeAttribut...
Read More