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

Building A Windows 8 Metro Style JavaScript / HTML5 / CSS3 App Using ListView


  Background The new Windows 8 Developer environment is seriously under documented at this point in it’s product life.  Microsoft released a “Developer Preview” at the Build Conference in September, than has not done any noticeable updates or improvement on those bits.  The Video’s online from build are very helpful because you can go through them in slow motion and see how to make things work.  In this article, I’m going to go through the steps necessary in a lot of detail to build a simple list read-only list viewer of US Congress legislators in California.  At the end, we’ll have something like the following working:   (actual tablet from build running the app)   and the completed solution from … Continue Reading

Microsoft To Add Auto-Compiled LINQ Queries to Entity Framework V.Next!


  In May of 2009 I discovered some significant performance problems that I blogged about.  In summary, I had tracked it down to the issue of LINQ2SQ having to create a full expression tree on every instantiation of a LINQ2SQL query.  I’m not a compiler write kind of guy but do respect the complexity of that and doing things like building expression trees, but still this really sucked.  Using the compile syntax in LINQ2SQL is very awkward, and IMHO takes all the fun out of using LINQ2SQL.  If you don’t remember my post, here is the graph showing the evil happening.   So, what is a Microsoft MVP to do?  I complained to everyone at Microsoft I knew.  I made this my mission for about a year.  I … Continue Reading


Get every new post delivered to your Inbox

Join other followers: