HttpWebResponse from WebException

1234567891011 using (var response = (HttpWebResponse)((Func)(() => { try { return(request.GetResponse());} catch (WebException ex) { return(ex.Response); } }))()) //<-- too funny using (var responseStream = response.GetResponseStream()) // ReSharper disable once AssignNullToNotNullAttribute using (var readStream = new StreamReader(responseStream, Encoding.UTF8)) { return String.Format("{0} {1}. {2}", (int)response.StatusCode, response.StatusCode, readStream.ReadToEnd()); }

Light Custom Configuration Section

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Configuration; namespace WebServiceClient { /*URLElement class below represents a bundle of properties (URL, password, etc) for each endpoint we need to send to... And the following custom app.configuration section allows us to maintain a list of these URLElements. copied from here: http://www.abhisheksur.com/2011/09/writing-custom-configurationsection-to.html and here: http://stackoverflow.com/questions/1755421/c-sharp-appsettings-is-there-a-easy-way-to-put-a-collection-into-appsetting The basic gist is 3 fairly light implementation classes -- URLElement = individual elements, URLCollection = collection of elements, and URLSection = new custom app.

SQL Server Table-Valued Stored Procedure Parameters <=> ADO.Net

Nutshell: Declare a User Defined Type (UDT) Declare a stored proc parm of that UDT Fill an ADO.Net DataTable with the same columns as the UDT Assign the DataTable to a Parameter of an ADO.Net SqlCommand corresponding to the sproc Notes: The Table-Valued Stored Procedure Parameters feature was first included in SQL Server 2008 Full working project source available here Code Examples: File_UDT.sql CREATE TYPE File_UDT AS TABLE ( FullPath varchar(900) PRIMARY KEY, ModifiedDate datetime, [Size] bigint ) GO GRANT EXECUTE ON TYPE::dbo.

CAC (SmartCard) Enabling ASP.Net on IIS

The only configuration settings required are (IIS7 screenshots below): Require SSL (this represents server side) and either Accept or Require Client Certificates … “Accept” will populate the SmartCard’s cert info to your ASP.Net Request object (if it’s provided) but won’t deny access if one hasn’t been provided, “Require” will deny access unless a valid SmartCard Cert has been provided. Tips: One key thing to be aware of how this works is that the server will send a list of Trusted Root Certificates down to the client/browser and then the browser will compare that list to the Trusted Roots represented by the CAC present and only if there’s a match will it prompt for the Certificate and PIN input.

2011 Q4 .Net State of the Union

.Net Framework v4 New Features Parallel Linq Extensions C# 4.0 New Features (all good stuff IMPO, variance being the hardest to grok) Named and Optional Parameters – already use this quite a bit Dynamic Support – handy way to ignore the complexity of ‘dynamically’ generated type declarations (e.g. linq results & COM Interop) Co/Contra-Variance – primarily intended to make .Net Framework methods with Generic type parameters like IEnumerable “_work like we’d expect_” as is often quoted in explanatory texts (look for Jon Skeet and Eric Lippert).

Evolving a custom ADO.Net based repository

Full GitHub Source demo post Concept A framework for maintaining column specific repository consistency with database update “side effects”. Prerequisites Stored procedures = business rules yep, i said it… My data layer is basically a home grown spin on ADO.Net Typed DataSets i.e. “Business” Class wrappers around ADO.Net classes (DataSets, DataRelations, DataTables, DataViews, DataRows, DataRowViews, etc).  I like to keep the majority of my business rules in stored procedures (“procs”).

YASBE – Open Source Code Incremental Backup Windows WPF Application

The reason I started this little project is none of the premier backup packages currently support Blu_ray… I know that sounds amazing but check out the help forums for stuff like Acronis and Paragon and Yosemite… it’s not a pretty picture out there currently with regards to Blu_ray… and of course, I had already bought my BD drive before I started to realize how dismal this all was… so I was inclined to find a solution 🙂

ASP.Net (& Ajax) Notes

It’s been long enough that the little things tripped me when I fired up a new project… so here they are for “next time”: new Guid() – this probably isn’t the one you want… it initializes to all zeros (i.e. {00000000-0000-0000-0000-000000000000}) System.Guid.NewGuid() is the one that generates a fresh unique value Getting “Automatic Compilation” to work (i.e. just uploading your source files to the web server and not your bin folder) Check the <%@ Page > directive & make sure it says CodeFile=”” not CodeBehind=”” If not then you’ll be getting errors like “Could not load type …” CodeFile came along with ASP.