Category

ASP.NET

Dynamic Content Detail Widget Templates in Sitefinity

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

Getting to Dynamic Content Data in Custom Code Behind In a previous post, I went over how you can easily create a custom code-behind C# class for any Widget Template in Sitefinity. Give that post a quick once-over, as this post builds upon that one. For built-in Sitefinity content items, accessing the data is pretty straightforward (see the previously-linked post): You grab the container, iterate over the items (even in the case of a single detail item), and then work with the data to make customizations to the page. For Dynamic Content Detail Widget templates, however, things work differently. You…

Read More

ConfigSource Your Rewrite Rules

By | .NET, ASP.NET, Web | No 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
aspnet-core-area-view-viewstart-layout

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
asp-net-core-area-index-view

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
SMTP4Dev Local SMTP

Test Sending Email Without an SMTP Server

By | .NET, ASP.NET, C#, Microsoft, Tools | No 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

QuerySelectorAll Error on BeginFormSitefinity

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

When developing a custom form on Sitefinity MVC widgets, the HTML helper method Sitefinity provides, Html.BeginFormSitefinity(), is a very handy resource. You wrap your form elements up inside the whole thing, along with a submit button, and you can point it at an HttpPost Action on your custom MVC widget controller with ease. When you’re putting your form widget on a master page, however, you can run into a rather vague JavaScript error that prevents your form from submitting correctly. The error in JavaScript brings up something about querySelectorAll and you’re left scratching your head as to what you did…

Read More

Widget Template Code Customized the Easy Way

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

Sitefinity’s Widget Templates provide a quick and easy way to change how Sitefinity renders widgets, both for built-in content types as well as custom ones. In the backend, it’s just a hop, skip, and a jump away to Design > Widget Templates to access a majority of the templates where you can manipulate the HTML used to render them. Oftentimes, though, you have to do more. Let’s say that, when iterating over a list of news items in the “Titles only” template you want to add a CSS class to some of the items, but not others. This goes beyond…

Read More

Using HandleUnknownAction in MVC Widgets

By | .NET, ASP.NET, C#, MVC, Sitefinity | No Comments

Sitefinity’s MVC widgets are fantastic. They allow untold amounts of customization and enable you to create an MVC framework as complex or as simple as you need. There is a caveat to using them, however: Because the controllers are typical ASP.NET MVC controllers, going to particular pages on your site might make them disappear! There is a simple workaround for this problem, and with this information you can ensure that your Sitefinity MVC widgets consistently display no matter what current state your web site is in. The Problem Say you have a simple custom MVC widget that has a single…

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 16 of 31 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 12 of 31 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 11 of 31 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

Using Azure DocumentDB with Cordova Tools in Visual Studio (or any JS client)

By | ASP.NET, Azure, Cordova, HTML5, iOS, JavaScript, Microsoft, Mobile, Multi-Device, News, node.js, Tools, Visual Studio, Web | 4 Comments

Abstract A few weeks ago, I set on a mission to learn more about Azure DocumentDB. My end goal was to use Azure DocumentDB with a JavaScript client application specifically with a Cordova app built with the new Tools for Apache Cordova or TACO which the team introduced a while ago. Background In April 2015, Microsoft officially released DocumentDB, its cloud, document oriented, NoSQL database (It was in preview since 2014). Azure DocumentDB, a new player in the NoSQL market, is built to work within the Azure Cloud ecosystem much like SQL Azure, SQL Storage, Azure search, etc. You would use DocumentDB…

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

Sitefinity Asynchronous Search with WebAPI

By | .NET, ASP.NET, C#, Fun, HTML5, JavaScript, Kendo UI, Sitefinity, Telerik, Web, Web API | One Comment

Overview Sitefinity CMS features a powerful internal Search Engine that allows your site visitors to search your content and find what they are looking for. The Search Engine is built on top of the .NET port of the infamous Lunene Engine which powers an unlimited number of websites today. Unlike the solid Search Engine behind it, the Search Widget which Sitefinity offers is not as mature. It provides the options to set up a basic search page and returns the results in a form of a list. Perhaps that will be satisfactory in most cases, but what if your requirements exceed…

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