asp.net Archives - Falafel Software Blog

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

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

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

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

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

It Takes a Lot of Chutzpah to Run QUnit and Jamsine Unit Tests in Visual Studio

By | ASP.NET, JavaScript, News, Testing, Tools, Web | One Comment

It’s never easy to unit test your code well, but to unit test your JavaScript code in Visual Studio takes Chutzpah. And I don’t mean it takes audacity in the classic Yiddish sense of the word, either. I mean it requires a Visual Studio extension called Chutzpah which can help you automate running your Jasmine, QUnit, or Mocha unit tests for your ASP.NET projects in Visual Studio. Chutzpah supports the two most recent versions of Visual Studio–VS 2012 and VS 2013–and it works with all types of ASP.NET projects. It’s really very simple to install. You can use the Extensions and Updates… option from the Tools…

Read More

Loading JavaScript and CSS Resources from Nested ASP.NET Partial Views

By | .NET, ASP.NET, News, Web | One Comment

The Problem When ASP.NET v4 was released, a cool feature from the beta was lost: the AssetsHelper class. Brock Allen has a great blog post explaining it and noting that it doesn’t exist in the RTM version. Basically, this helper class would allow you to emit some scripts and stylesheets from a partial view and have them bubble all the way up the tree of view elements to the layout where they would be displayed with all the other js and css files emitted by other parts of the view. For example, this partial view can render to assets:

And those assets can be…

Read More

Add Namespaces to Sitefinity RSS Feed

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

Alternative Publishing is a useful feature of Sitefinity. I’ve been using it since a long time but recently I had a situation where I needed to add Dublin Core Metadata Element Set elements like and . So I tried to figure out how to include http://purl.org/dc/elements/1.1/ namespace in the feed Sitefinity generates, and here’s the solution. When you override RSSOutboundPipe class, override BuildSyndicationFeed method to add namespaces.

Read More

Server Paging, Sorting, and Filtering with Kendo DataSourceRequest

By | ASP.NET, C#, Kendo UI, MVC, Telerik, Web | 13 Comments

As you would expect, the Kendo UI Grid and DataSource work extremely well together and give you paging, sorting, and filtering right out of the box.  By default, the DataSource will do all of this on the client which is fine for small sets of data, but it becomes a huge performance issue when you are dealing with thousands of records.  In this case, we need to move this work to the server. I typically do not endorse using the Kendo MVC Extensions for large applications (you get more flexibility and a cleaner architecture when you write your own Javascript),…

Read More

HTTP GET array param to ASP.NET MVC with Kendo DataSource

By | .NET, ASP.NET, JavaScript, Kendo UI, MVC | No Comments

This post is inspired by a recent conversation with one of my colleagues here. He had the following requirements: ASP.NET MVC controller (not Web API) Kendo DataSource reading with HTTP GET Controller action accepts a list of values So, something like this:

This is an awkward little corner case. Change any one of the requirements and everything will work just fine. Fresh out of the box, Web API understands sending multiple values in the query string (at least, with the right controller action method signature). MVC controllers understand arrays if they’re posted in the body of the request,…

Read More

Domain-Driven Design with ASP.NET MVC

By | Uncategorized | 2 Comments

I’ll be speaking on about Domain-Driven Design, or DDD, with ASP.NET MVC at this year’s FalafelCON event, taking place 20-21 September 2014 in San Francisco.  The event is limited to the first 200 people to register, so if you’re interested in attending, you may want to register today.  DDD is a big topic, and one I’ve been interested in for many years now.  In fact, I recently published a course on DDD Fundamentals with Julie Lerman for Pluralsight that covers the basics.  If you have a chance to watch it, let me know what you think via the course’s discussion…

Read More

Sitefinity Real-Time Notifications with SignalR

By | Sitefinity | No Comments

One of the more interesting technologies I discovered during my recent trip to Tech Ed 2014 is SignalR, which is a library for ASP.NET that allows real-time communication between the server and browser. This exciting platform enables bi-directional communication between a page and the server, allowing updates to be instantly pushed in either direction. Best of all, SignalR automatically detects the best option for communication based on the capabilities of the client ensuring maximum compatibility across different browsers.

Today we’ll see how you can setup Sitefinity to use this library with a simple notification that fires when a user logs into the backend. Later we’ll build a more real-world scenario by building a real-time viewer count for a blog post.

Read More

Tech Ed 2014 Day Two

By | Microsoft | No Comments

Day one at Tech Ed already set the bar high, but day two just smashed it open. So much going on, and it’s way too much content to cram into a summary. Look for full, dedicated posts on some of these topics in the coming days and weeks as I dive deeper into my notes and re-watch the videos (not to mention the ones I missed)! The Future of .NET on the Server – Scott Hanselman took another look at the topics previewed about .NET vNext yesterday, then took an even deeper dive in the next session. There’s some really…

Read More

Tech Ed 2014 Day One Recap

By | Microsoft | No Comments

What a day, full of sessions, lessons, great people, and great information; I can’t wait to take in more on Tuesday. If you’d like to say hi, be sure, ping me on twitter @SelAromDotNet, I’d really appreciate the opportunity to meet you in person! Here are some of the highlights from Monday that still have my developer senses tingling! Visual Studio 2013 R2 RTM – Official release of the latest update to Visual Studio. Considering that the RC is only just over a month old, this is a testament to Microsoft’s increasing commitment to rapid iteration and release. This update…

Read More

Preventing default action for an element in AngularJS

By | Web | One Comment

Assume you have an anchor button and you want to prevent default action of the anchor tag in a app using AngularJS. The code below shows you how – HTML <a class=”button” href=”#” id=”setFilterButton” ng-click=”setFilters($event)”>Set Filter</a> HTML above is pretty straight forward and something you will find with any ng-click with one exception. We are now passing $event to ng-click. We will make use of $event in our controller to prevent the default action. Javascript $scope.setFilters = function (event) { event.preventDefault(); console.log(‘Clicked!’); }; So in the controllers setFilter method we accept the event parameter passed from HTML and just call…

Read More