Programming

A collection of 35 posts
Operations

WCF with HTTP and HTTPS

OK, this is really, really annoying. You should NOT have to do any config to support the 2 most widely used protocols on the internet, HTTP and HTTPS. Here's the simple, really simple, web.config to support both HTTP and HTTPS. You don't need all the attributes to do it, if you don't specify them, it will use the defaults. So, for simplicity sake, I didn't put them in. This is an example that I couldn't find on google....so here you all go. <system.serviceModel> <bindings> <basicHtt
1 min read
Operations

Multiple Config Transforms on Single Element

Hey everyone, so, I had a need to set some attributes and remove 2 of them in my web.config transform file. On my development system, I have my WCF services all pointing to my local fiddler, for debugging? Anyways, I needed to remove the proxyAddress attribute and also set the useDefaultWebProxy, and securityMode. You can't put in 2 different transforms in the same element doing something like xdt:Transform="SetAttributes(useDefaultWebProxy),RemoveAttributes(proxyAddress)". The msbuild app puk
1 min read
C-Sharp

EntityFramework, slow insert and SqlBulkCopy

Hey all, I finally got fed up with the ridiculously slow insert times of EntityFramework. So, I went with the SqlBulkCopy route, but that required a second connection to the database, and second connection string in the config file, you're not storing them in the code right...? Well, I created some extension methods to handle this all for me, this takes care of getting the SqlConnection out of the Entity Context. Below is the code to do it. public static class ObjectContextExtensions { ///
1 min read
C-Sharp

Converting non MVC3 projects to MVC3 projects

Well, I needed to do this because the project that the codgen tool in Orchard creates is not an MVC3 project. Call me picky, but I like the Add Control, Goto View, Create View, and all the other cool little things that come with an MVC project in Visual Studio. So, I set out to figure out how to do it. It's pretty easy, in the .csproj file, there is a project type GUIDs element. Starts out as something like this: <ProjectTypeGuids>{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> just
C-Sharp

iTextSharp and Windows SSL Certificates

Well, it took a bit of work, but I figured out how to add certificates and intermediate certificates into a PDF document while signing it using iTextSharp. The examples they had were close, but not quite there. They had hard coded the buffer size to 4000. Seemed a bit small, it got real tight when I had 2 intermediate certificates, so I made a change to that to use a more dynamic approach. I did a 4000 + RawData.Length for each certificate. Definitely opened up some more room to fit everything i
3 min read
ASP.Net

Session state on end of every request in asp.net

I had a need to access the session state on the end of every request, even those on Response.Redirect. It sounds simple, and it is. It just took a while to find out what method is always called on every page before the data (headers and content) is sent back to the client. Even on Response.Redirect's.In the global.asax file, it is the method Application_PostRequestHandlerExecute. It is the last method that is called that has access to the session state. Here's a basic example: using System; usi
1 min read
Operations

DNN and Asp.net 4.0 Broken Captcha.aspx and LinkClick.aspx

Well, I ran into a problem with my captcha stuff on my blog, it wasn't working. Just displaying a red X. I am on a 2008 R2 server with IIS7.5 and .NET 4.0 64-bit. The fix was simple. I had to change the handlers in the web.config. Specifically the preconditions. The used to be integratedMode,runtimeVersionv2.0. You can either change them to integratedMode,runtimeVersionv4.0 or just remove them. In the section, remove the preCondition stuff from the entries pertaining to dotnetnuke. All of mine
1 min read