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

All ASP.NET MVC Forms Need To Include Html.AntiForgeryToken() For Security

Having recently been implementing many new form pages in ASP.NET MVC, I’ve found myself over and over again adding the following two things to every form. After Html.BeginForm() I Put @Html.AntiForgeryToken() Add the Attribute [ValidateAntiForgeryToken] To Every Post Action Method Before I was doing so much ASP.NET MVC, I would often see in Channel 9 videos, the presenter add the AntiForgeryToken() after the BeginForm() method on the cshtml razor page and say something like “you should always add this”.  I never saw them say “and don’t forget to add the attribute ValidateAntiForgeryToken to the controller POST method. Just to be clear, below is what I’m talking about: What this does is to make sure that the trusted … Continue Reading

Safely Encoding Strings On ASP.NET MVC Razor Pages (sometimes)

  Background Sometimes, we want to let html tags come through our web pages from user defined content.  If for example, you have a workflow that requires approval before publishing, there are times when you want to let the author put through html, links, etc.  Solution In Visual Studio write a simple HtmlHelper method that allows for a flag you can pass through.  In my case, I have a database table with a boolean column “allowhtml”.  If this is set, then instead of using Html.Raw(…) I can use my own helper method, pass in the allowHtml value and if it is set true, then allow the not encoded Html to flow through. Here is that helper method: namespace WebAPI.Code.Helpers { public static class … Continue Reading

Capturing SendGrid Events With ASP.NET WebAPI and Task async

  Problem I’ve been using SendGrid’s API WebHooks to capture email events (Version 1).  This version sends one event at a time which has always been a pretty bad idea.  When I first did the integration a year or so ago, the only way to capture multiple events at once was to consume some proprietary non-JSON like protocol.  I declined.  They finally have upgraded the API to send standard JSON records and are going to obsolete version 1 so I need to change.  Here goes… Send Grid Event Notification Configuration First, you need to go into Event Notification and change to (v3) of the config.  Then, I pressed the “Test Your Integration” button while running fiddler to grab the JSON SendGrid generates (see … Continue Reading


Get every new post delivered to your Inbox

Join other followers: