Redis Conference Talk on Fast Cache with ASP.NET by Peter Kellner

Back in May, I gave a 45 minute talk at the 2016 Redis Conference in San Francisco.  The talk titled “Using Redis as Distributed Cache for Microsoft’s ASP.NET apps” was well received in spite of my opening line stating that I don’t know anything about Redis. The basics are I Compiled The Redis Server From Source Implemented a Redis Client in C# Demonstrated Reliable Caching in ASP.NET to a Redis Server   You can watch the full video on you tube at this URL. … Continue Reading

Using Type T for making C# Method Calls More Flexible

I often find myself getting lazy and making multiple entry points for a method when I really should spend an extra 30 seconds and use the Type T pattern in C#.  Below are the two calls I had and when I started writing the one that returns int, I decided enough was enough. private static bool GetWorkshopTopLevelPropertyBool(JToken jToken, string attr2) { return jToken["workshopResults"][attr2].Value(); } private static string GetAttendeeInfoString(JToken jToken, string attr) { return jToken["attendeeResults"][attr].Value(); } Here is the generalized verison of the same code but only has to be written once. private static T GetAttendeeInfo(JToken jToken, string attr) { return … Continue Reading

Parsing NewtonSoft JToken Inside WebAPI Call

One of the simplest ways to POST data from a JavaScript app (such as Angular or JQuery) to a Microsoft ASP.NET WebAPI endpoint is simply to post JSON data.  There is a lot of magic that happens to try and match up the POST data you are calling with to the WebAPI call and it often feels like there is no reason why some calls work and some don’t. My experience is that it’s easier to just process generic JSON on the WebAPI side and not worry about the shape of the data until after it arrives on your WebAPI endpoint.  Darrell Miller has a very helpful article that demystifies that data and give a very clear way to get that JSON to your WebAPI endpoint as a NewtonSoft JToken.  Darrel leaves out what to do with the JToken so I thought I’d fill … Continue Reading

Converting a Controller Method in MVC5 to async

I’m currently working on a Pluralsight course on ASP.NET and I have to admit I’m slow to adopt async methods in my code because it feels a little complex when non-async code is what I’m use to.  I’m feeling like since I’m doing this Pluralsight course I should really show best practices and clearly async controller methods is no doubt a best practice. I’m surprised it was actually so easy.  First, let me show you the code that I had written that is not async that I’m sure you are all familiar with. [crayon-579972c473a72882572953/] All I had to change (besides adding the async name space for Task) was to have speakers return a task with the ToListAsync method and change the signature of the method to return a task. Here is the updated … Continue Reading

Follow

Get every new post delivered to your Inbox

Join other followers: