ConfigSource Your Rewrite Rules

By | .NET, ASP.NET, Web | 2 Comments

When your Web.Config Gets too Big Maintaining a web.config in your ASP.NET application can quickly get out of hand. It contains the bulk of your web application’s settings and configurations, and even the fresh, out-of-the-box version is several hundred lines long. If you have a set of IIS URL Rewrite Rules to maintain in the same file, the web.config can become immense. This is where using configsource can come in handy. Benefits of ConfigSource In my view there are some large advantages to separating your list of rewrite rules out from the web.config file into a separate, configsource-appointed config file….

Read More

Set Layout for Views in MVC Areas

By | ASP.NET, ASP.NET Core, MVC | No Comments

Here’s a quick tip follow up for my last post on working with MVC Areas with ASP.NET Core. When I visited the pages in the new Admin area I created, it was obvious that they were not picking up the layout and style from the other pages in the site:   To fix this I needed to add the Layout property to the View:

Alternatively, you can create a file named _ViewStart.cshtml with just the layout definition and place it in the Views folder for the Area. This approach will make all views automatically use the defined template. This…

Read More

MVC Areas with ASP.NET Core

By | ASP.NET, ASP.NET Core, MVC, Web | One Comment

Areas in MVC allow you to separate your web application into segments, each with their own set of Controllers and Views, for better organization and intuitive access via routing. I decided to play with this MVC Areas feature in ASP.NET Core and thought I’d share my experience in case it might help others using this feature. My first attempt to use this was to simply add the Areas folder to the root of my application, with a subfolder called Admin with the associated folders for Controllers, Models, and Views: I added a simple AdminController to simulate a separate Administration section…

Read More

Test Sending Email Without an SMTP Server

By | .NET, ASP.NET, C#, Microsoft, Tools | 2 Comments

When working on a project, I had the need to locally test the sending and formatting of an email from an application. The only downside is that I don’t have an SMTP server on my workstation, and I wasn’t about to start setting up IIS with all that ceremony. Luckily there are a couple tools that can help with this problem. Neptune The first tool I tried was Neptune. It doesn’t have source code available, but if you need a way to see if an email has been sent, it will show up with a notification in the system tray. You…

Read More

Web API Route Design for Non-CRUD Routes

By | ASP.NET, Web API | 2 Comments

Introduction I’ve been finding myself thinking a lot about route design for the web APIs I’ve been building lately. For your basic CRUD (Create, Read, Update, Delete) controllers, everyone knows that the POST HTTP verb maps to create/insert; GET maps to read/select; PUT maps to update; and DELETE maps to–brace yourself–delete. But what about routes that represent things beyond these fundamental but basic data manipulations? I’ve done a bit of reading and thinking about the subject, and these are a distillation of the lessons I’ve learned. URLs represent resources I mean, it’s right in the name: Uniform Resource Locator. But what…

Read More

Kendo UI: Easily share templates in ASP.NET MVC

By | ASP.NET, Kendo UI, News | 3 Comments

Sharing Kendo UI templates among multiple pages in your web application is not a straightforward task.  The Kendo UI documentation does provide a detailed explanation of how to accomplish this but it requires an abundance of messy code.  Fortunately though, if you happen to be using ASP.NET MVC there is a much simpler way with the help of Partial Views.   First create a partial view that includes the templates:

    And finally render the templates partial view in your page:


Read More
Azure Preview

Using Azure Media Services to Encode, Host, and Transcribe Video

By | ASP.NET, Azure, HTML5, Microsoft, Mobile, Multi-Device, Tools | One Comment

This is post 14 of 29 in the series “A Cloudy 29 Days of Microsoft Azure” Azure Media Services has proven to be a one stop shop for all of your video needs. Azure Media Services includes encoding, encrypting, transcription and hosting services, basically it does everything except for shoot the raw video. Choose to deliver video on demand or stream video live, both of these delivery scenarios provide adaptive bitrates for optimal viewing. Consuming video in your applications couldn’t be easier than using Azure Media Player, as it brings a multi-device, multi-browser supported media player. Azure Media Services also…

Read More

Azure Search – A Managed search as a service in the cloud

By | ASP.NET, Azure | 2 Comments

This is post 11 of 29 in the series “A Cloudy 29 Days of Microsoft Azure”   In today’s article we will look at how Azure Search can you help you with a fully managed search-as-a-service in the cloud.   It is really easy to get up and running using Azure Search and Azure Search also has the Azure’s scaling capabilities which lets you easily scale up and down the service to meet your needs.   To get started with Azure Search, click New in your Azure Management Portal and in Data + Storage section, you will find Azure Search…

Read More

Azure Redis Cache, the fast in-memory cache service

By | ASP.NET, Azure | 2 Comments

This is post 10 of 29 in the series “A Cloudy 29 Days of Microsoft Azure” Redis is an in-memory key-value store and Azure Redis Cache provides us with the power in-memory cache service and adds all the things we love above Azure such as scalability, security etc. Let us explore how to use Azure Redis Cache in this post   Creating To create a Redis Cache in Azure, logon to your management portal, click on New then Data + Storage and then Redis Cache Then enter the DNS name, which will serve as a host name for your Redis…

Read More

How to Upload Files to your Sitefinity Document Library Asynchronously

By | .NET, ASP.NET, C#, JavaScript, Sitefinity, Web API | 2 Comments

Sometimes, it is necessary for users of your site to be able to upload files to Document Libraries in an asynchronous manner. They could be creating user-generated content and require a space to upload a file to reference in their content, for instance. Using some JavaScript and an ASP.NET WebAPI controller, we can accomplish this fairly simply. The HTML The first thing we’ll need is an input that allows users to select a file. This’ll be a simple HTML input the “file” type. You can put this HTML (along with the associated JavaScript) anywhere on the page, either via Content…

Read More

Await in Catch and Finally blocks – Day 13 – VS2015 Series

By | ASP.NET, Visual Studio | 2 Comments

This is post 13 of 31 in the series “31 Days of VS2015 Tricks and Treats” Await in Catch and Finally blocks Of all the language additions in C# 6 the added ability to use await in catch and finally blocks is likely my favorite. Previous to C# 6 one couldn’t. This inability could be particularly irksome as it created a conflict between two common good practices: Posting event to logs asynchronously so move the overhead of log I/O out of band from the application Logging errors as they occur. Since exceptions are handled by catch blocks with detection only being…

Read More

Storing Sitefinity Sites In Source Control

By | .NET, ASP.NET, C#, Sitefinity | 5 Comments

Issues with Content Management Systems and Source Control When developing a Sitefinity web site, you run into some challenges when it comes to properly storing your work in source control. Out of the box from its project manager, Sitefinity houses its references in the bin directory of the application so that a project build is not required to get it up and running. Being a content management system, a lot of changes occur in the site’s database. When developers want to put their Sitefinity site in source control and wish to collaborate, these sorts of issues can be difficult to…

Read More

Sitecore – Configuring Web API

By | .NET, ASP.NET, C#, News, Sitecore, Web API, WebUI | 2 Comments

Web API is useful in many situations, and Sitecore comes with a great Item API. But if you want to have your own API endpoints in your web application that is using Sitecore, there is a small extra step you need to take. The traditional ASP.NET Web API set up involves registering your API and configuring your routing with something like this:

This will trigger the registration during the standard .NET pipeline to register your routes and configurations. However, when using Sitecore, you are forced to work within the Sitecore Pipelines which may not trigger the API registration as…

Read More

Sitecore – Remove Spaces from URLs

By | .NET, ASP.NET, C#, Sitecore | One Comment

The URLs that Sitecore generates come from the Item Paths of the Sitecore Item being presented, and of course the Item Paths come from the name of the Item and its parent Items. It is typically bad practice to use spaces in your URLs, and using Sitecore’s built in space separated paths not only looks ugly in the URL bar, but can also be a problem if you are moving an existing site over to Sitecore if you want to retain your URLs for SEO purposes. Here is a quick and easy way to handle the Item naming so that…

Read More

Sitecore – Removing Languages from Urls

By | .NET, ASP.NET, C#, News, Sitecore | No Comments

The embedding of the current language in the URL is an awesome feature that Sitecore offers out of the box. However, there isn’t always the need for it and sometimes it can even be an inconvenience. You may want to remove languages for SEO purposes, to keep existing URLs from your previous site indexed if you are migrating to Sitecore, or just because you don’t like the way it looks. There is a few places this is handled by Sitecore. At a high level, there is a setting in the Web.config, and at an individual level from code (LinkManager.GetItemUrl()). In the Web.config:


Read More

File Downloads with ASP.NET MVC

By | .NET, ASP.NET, MVC | 5 Comments

So you need to download a file to the browser with ASP.NET MVC? Let’s take a look at a simple example, starting with the Controller’s Action method. Controller Code System.Web.Mvc provides a few different types of FileResult (which derives from ActionResult): FileContentResult, FilePathResult, and FileStreamResult. However, since they all derive from FileResult, we can simply use FileResult as our return type.

In this example, we are using an ID to look up some sort of data and create a MemoryStream that contains the file contents. If the data already exists as a file on the server’s file system, you would only…

Read More

How to use SignalR with Kendo UI

By | .NET, ASP.NET, Kendo UI, News | 4 Comments

Why SignalR? For most Kendo projects that I’ve been involved with, Kendo UI consumes JSON data originating from an ASP.NET controller (either a JsonResult action or a WebAPI action). The lifecycle is pretty straight-forward: the DataSource reads the initial data, and then a separate AJAX postback is performed for each create, update, and destroy operation. The problem with this is that the user is looking at a snapshot of the data. Suppose that another user is also looking at that data, and decides to change it. How do we alert the first user that their data is stale and needs…

Read More

The Best Developer Articles of 2014

By | AngularJS, ASP.NET, Kendo UI, Telerik | 2 Comments

It’s a new year, sure, but we we’re not quite ready to give up our most popular articles of 2014. From simple tips to deep dives into code, these posts have it all! AngularJS and Kendo UI – Part 1 – Getting Started We’re bringing together two themes I’ve been developing for the past few months: AngularJS and Kendo UI. These technologies go together like peanut butter and chocolate, and both share two characteristics that are critical to this series: The technology is hot, desirable and useful The reference documentation is very good, but good tutorials are in short supply…

Read More