asp.net-mvc

Extending RestSharp to Handle Timeouts in ASP.NET MVC

We're working on a large project which consumes a custom-build API, and one of the requirements of this project is that if the API goes down, certain sections of the website still need to be able to function. The reason for this is that our app consumes a lot of APIs and services, and occasionally a non-critical one will go down (for maintenance, bugs, whatever) and we don't want our site to crash as well, since this was a problem... Read more >

Consuming Web API Custom Validation in MVC using RestSharp

I previously wrote a post called Custom Validation in ASP.NET Web API with FluentValidation, in which I showed how my group set up a validation framework over WebAPI using the FluentValidation NuGet package. In this post, we'll go over how to consume those responses in an ASP.NET MVC app, as well as how to take the error messages from the API response and automatically add them to the MVC ModelState. I have updated the sample project on GitHub... Read more >

What are Areas? - ASP.NET MVC Demystified

ASP.NET MVC relies on certain conventions (both naming and placement) to properly route requests and return views and view models. One of the ways it allows us programmers to manage these conventions is with the use of Areas, which are modules within an MVC project that exist with their own controllers, views, and actions. Let's learn how we can add Areas to an existing project, and what their separation from the main project allows us to do. What are... Read more >

Using Partial Views - ASP.NET MVC Demystified

When I was writing applications in WebForms (which, thankfully, I no longer do) I often ended up used .ascx files, commonly known as User Controls. Once I moved to MVC, I had to get used to a similar (though not the same) concept: Partial Views. In this tutorial, we'll walk through a use case for Partial Views and explain what they are and why we need to use them. We'll also walk through the two different render methods: @Html.Partial(... Read more >

Using the _ViewImports.cshtml File to Set Up View Namespaces in MVC 6

As of Beta 5 of ASP.NET 5, there is a new file in the Views folder of an MVC project called _ViewImports.cshtml (here's the GitHub item). In previous Beta versions, this file was called _GlobalImport.cshtml; even though it has been renamed, its functionality is the same in Beta 5 as in Beta 3. What exactly does it do? Let's find out! Purpose _ViewImports.cshtml serves one major purpose: to provide namespaces which can be used by all... Read more >

An Overview of Tag Helpers in ASP.NET Core

I was a little hesitant about the new Tag Helpers feature coming out with ASP.NET Core and ASP.NET MVC 6 when I last wrote about it, but a few recent updates have totally changed my mind. These things are going to be awesome. Are you still trying to understand what tag helpers are, and why we'd use them over good old Razor helpers? Then read on! Here's the sections in this tutorial: What's a Tag Helper? The Completed... Read more >

Attribute Routing vs Convention Routing - ASP.NET MVC Demystified

For most of ASP.NET MVC's lifetime, routing has been accomplished via Convention Routing, which allows developers to specify a format or group of formats which can be used to parse incoming URLs and determine the appropriate actions, controllers, and data to use for that request. In MVC 5, though, Microsoft introduced another scheme called Attribute Routing. Attribute Routing allows us to define routes in close proximity to their actions, giving us greater flexibility. Let's dive into Routing as a... Read more >

Tag Helpers in ASP.NET 5 Beta 3

NOTE: I have written a more updated tutorial on Tag Helpers. Check it out! I mentioned in Welcoming the Coming Death of WebForms that one of the features I was most excited about in ASP.NET 5 was Tag Helpers. I've finally gotten some time to install VS 2015 CTP 6 and try this feature out, and I'm pretty impressed by these early examples. Why use Tag Helpers? Because it gets us closer to the ideal webpage that's written only... Read more >