Skip to main content

Layout Views

Layout views in MVC are similar to Master pages in ASP.Net. Layout view contains page template. Layout view contains common part of page such as header, sidebar, menu and footer. Generally there are few layout view and multiple views. If we want same header , footer and side bar on multiple pages then we can […]

Read More

Shared View in MVC

Any view that can be used by multiple controllers is known as shared view. It is placed in ‘Views\Shared’ folder. There can be more than one shared view in MVC application. For example , there are two controllers ‘Customer’ and ‘Agent’. We want to display same Contact view for both controllers. Action method Contact() will […]

Read More

Razor Advanced Syntax

In this article, I will explain advanced syntax in Razor. Please read my previous article Razor Syntax before reading this article, I have used project sample from article Razor Syntax . Conditions in Razor We can use ‘If else’ in Razor to display content based on some conditions. For example, if OrderAmount is greater than […]

Read More

Razor Syntax

Whenever we create a View with .cshtml extension, then View is called as Razor View. In Razor View, we can use C# and html together. Now I will create a view and pass data dynamically to the view and use Razor syntax to display that data. I have created an action method CustomerDetails() in Home […]

Read More

RedirectToRouteResult in MVC

In this article we will learn about RedirectToRouteResult class.Object of this class represents redirection from one action method to another method within a web application. It sends HTTP 302 response to browser so browser sends another request to new action method. For example, if login is successful then user will be redirected to dashboard else […]

Read More

RedirectResult in MVC

RedirectResult represents redirection from an action method to other website. Action method send http status code 302 to browser, after receiving 302 response, browser sends another request to target URL. We use Redirect() method to create and return an object of RedirectResult class. For example, from action method we want to redirect to facebook profile […]

Read More

FileResult in MVC

We use FileResult when we want to return a file as a response to browser.Sometimes user may need to download specific files from application such as order details in pdf format or user guide for instructions. Now we will see the code for downloading file using FileResult. FileResult is child class of ActionResult class. In […]

Read More

ContentResult in MVC

Please read my articles First MVC Application and ActionResult in MVC before proceeding further in this article. In this article we will learn about ContentResult. We can use ContentResult if we want to return some content along with content-type from an action method. The content-type can be plain text, html, css or xml. For example […]

Read More