Dot Net Stuff

Attributes in Routing in ASP.NET MVC with example:

Routing in Asp.NET MVC is how ASP.NET MVC matches a URI to an action. ASP.NET routing enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users. You can find more details about ASP.NET MVC Routing in separate articles. Here, I am going to discuss about Attributes in Routing in ASP.NET MVC.Now, you are able to know what following code says.

Continue Reading>>

Understanding Routing in ASP.NET MVC with example

Routing in Asp.NET MVC is how ASP.NET MVC matches a URI to an action. ASP.NET routing enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users. It is a part of all the MVC versions but MVC 5 supports a new type of routing, called attribute routing. As the name implies, attribute routing uses attributes to define routes. Attribute routing gives you more control over the URIs in your web application. There is a separate article to understand Attributes in Routing in ASP.NET MVC.

Continue Reading>>

What is ASP.NET Web API ? Why to Choose ASP.NET Web API ?

ASP.NET Web API is a framework that allows us to build HTTP services that reach a broad range of clients, including browsers, mobile devices, and tablets. For creating RESTFul applications, ASP.NET Web API is an ideal platform on the .NET Framework. As it contains ASP.NET MVC features such as routing, controller, action results, filter, model binding, thus it is very easy to create application for ASP.NET WEB API. Here, one thing we should keep in mind that Asp.Net Web API is not a part of ASP.NET MVC. ASP.NET Web API is a part of code ASP.NET platform and it can be used with ASP.NET MVC or any other types of application or it can be a standalone service application.

Continue Reading>>

Differences between Functions and Stored Procedures SQL Server

A lot of beginners have confusion about stored procedure and functions in SQL Server. Here, I am explaining the definition and the differences between stored procedure and functions.

What is Stored Procedure ?

We can define "Stored Procedure" is a group of sql statements that has been created once and stored in server database. In another way stored procedure is a pre-compile objects which are compiled for first time and its compiled format is saved and there are executes whenever stored procedure is called.Continue Reading>>

Understanding Generic Anonymous Methods and Lambda Expressions in C#

Anonymous methods behave like regular methods except that they are unnamed. Anonymous Methods were introduced as an alternative to defining delegates that did very simple tasks, where full-blown methods amounted to more than just extra typing. Anonymous methods also evolved further into Lambda Expressions, which are even shorter methods.

Continue Reading>>

Understanding and Programming with Anonymous Types in C#

Anonymous types use the keyword var. Var is also used in Pascal and Delphi today, but var in Delphi is like ByRef in Visual Basic (VB) or ref in C#. The var introduced with .NET 3.5 indicates an anonymous type. Now, our VB friends are going to think, “Well, we have had variants for years in VB.” But var is not a dumbing down and clogging up of C#. Anonymous types are something new and necessary.

The simple meaning of Anonymous is that you don’t specify the type. You write var and C# figures out what type is defined by the right side, and C# emits (writes the code), indicating the type. From that point on, the type is strongly defined, checked by the compiler (not at runtime), and exists as a complete type in your code. There is one point to remember, you didn’t write the type definition; C# did.

Continue Reading>>

Understand ASPX and Razor View Engine

ASP.NET MVC is one of the most popular frameworks for these days and the term “View Engine” is belongs to that. I this section we are try to understand about Razor View Engine and ASPX View Engine.

Introduction of View Engine

There are two types of view engine supported by ASP.NET MVC. In this Article we will go through the Razor and ASPX view engine View Engines are responsible for rendering the HTML from your views to the browser. The view engine template will have different syntax for implementation.

What is @Razor ?

Razor using an @ character instead of aspx's <% %> and Razor does not require you to explicitly close the code-block, this view engine is parsed intelligently by the run-time to determine what is a presentation element and what is a code element. Razor view engine is compatible with unit testing frameworks. This is the default view engine in MVC 3 and MVC 4. Web pages with Razor syntax have the special file extension cshtml (Razor with C#) or vbhtml (Razor with VB).

Continue Reading>>

Dependency Inversion Principle, Dependency Injection and Inversion of Control (DIP, IoC and DI)

So, there are a lot of confusion in developers mind regarding Dependency Inversion Principle, Dependency Injection and Inversion of Control, that’s why I tried to explain as par my experience. We need to understand a bit of Software Design Principle & Software Design Pattern. Dependency Inversion Principle (DIP) is a Software design principle and Inversion of Control (IoC) is a Software design pattern. Let's see what is Software design principle and pattern.

Software Design Principle:

Principle provides us only guideline to achieve some task. Principle tells us what is right and what is wrong. It doesn’t say us how to solve problem. It just gives some guideline so that we can design good software and avoid bad design. Some principles are DRY, OCP, DIP etc.

Continue Reading>>

Understanding and Implementing Inversion of Control Container (IoC container) using csharp

Inversion of control (IoC) describes a design in which custom-written portions of a computer program receive the flow of control from a generic, reusable library. A software architecture with this design inverts control as compared to traditional procedural programming: in traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the reusable code that calls into the custom, or problem-specific, code.

Let's try to understand the inversion of control in with an example. Suppose, we have a console application with a sequence of commands like "Enter name", "enter address"; this program would drive the prompts and pick up a response to each one. With graphical (or even screen based) UIs the UI framework would contain this main loop and your program instead provided event handlers for the various fields on the screen. The main control of the program was inverted, moved away from you to the framework.

Continue Reading>>

Understanding Dependency Injection Pattern in C-Sharp

We have discussed Dependency Injection (DI) as a separate article; here we only try to know the core concept of Dependency Injection (DI). A type of IoC where we move the creation and binding of dependency outside of the class that depends on it. In normal object are created inside of the dependent class and bounded inside the dependent class. In Dependency Injection (DI) it is done from outside of the dependent class. There are three type of Dependency Injection (DI).

  1. Constructor Injection
  2. Setter Injection
  3. Interface Injection
Continue Reading>>