Category Archives: .NET

So as I was working on the Direct Sales CRM application, I came to the part where I needed to upload CSV files to be imported / processed.

From the early days of webforms, I recalled this being quite a pain in the neck.

And, honestly, I wasn’t looking forward to figuring out how to make it work in MVC.

But, boy was I worrying about nothing. NOTHING.

It was so stupid simple, I had it completely implemented, including saving a reference record of the file to the database, in a matter of a few hours.

The following code is a verbatim copy from http://www.aspdotnet-pools.com/. Not that anything will happen to it, but I’m a digital hoarder and would also like a place for me to reference in the event something changes on their end.

As you may have noticed, I took out the solution file for this project, since it should reside outside of the project file.

I ran the rename commands in my VSCP, and voila. Files were moved.

Now that the files were moved, I had to update the solution file to accommodate for the newly moved folder. Hopefully you’ve had some experience in doing this, but it’s really not that hard if you haven’t before.

Simply locate the “Project” line, as well as any “PhysicalPath” properties for the web application directory, and update them to be “Web\”. Save the file, and then open it as usual.

So I’ve been reading a lot and listening to a ton of success and business podcasts, and have decided I would like to set a S.M.A.R.T. goal. For those of you who don’t know, it’s an amazing thing to use when making goals.

Below is my breakdown of my goal.

Specific – The 70-516 exam
Measurable – I will take the test
Achievable – This should be achievable given the 11 or so week time frame
Relevant – This is in line with my current career path (and ultimate MCPD goal)
Time-Bound – I will take the test on Saturday December 13, 2014

Why 11 weeks? Well, I currently have a few things that are a bit more pressing:

Fixing up and then selling my house in Cheyenne (nearly there)

Expecting a new addition to our family (End of November)

Have a few quick (hopefully) side projects I would like to complete

I ordered the self-paced study guides from Amazon (at $4-$5 each, how could you go wrong?), as well as ordered a practice exam for my phone.

So my spare time will be taking short practice exams, or studying/implementing the study guide. Either way, my time will no longer consist of playing solitaire or browsing the community shopping pages on Facebook.

Just think: Using your spare minutes during the day and a few hours a week, you too could have yourself a certification in your desired field. Will you commit to yourself to bettering your career? Let me know in the comments below, or shoot me an email via my contact page. Maybe we can hold each other accountable for our next tests.

While working the day job, I am porting over some sites from one virtual site to another.

Our clients will typically have their own external domain, which will get http redirected to a client specific sub-domain. Unfortunately, each external website has pretty much the exact same redirect page, under construction page, landing page, etc. The only difference is the redirect URL. Which, luckily in our case, can be found in the database (though, not really used).

During a deployment, we must manually turn each of the default pages to use the Under Construction page in IIS. This will prevent the redirect from occurring. However, you can see how the success of our company could lead to 4 hour long deployments, just in switching the default page.

“Why not script it?” you might be asking… That’s really the equivalent of saying “buy a nail gun if you’re nailing things” and not asking the question “is this implementation the right implementation?” In this case, it’s not.

I wrote an app that will determine the exact same thing, and do it in a fraction of the footprint, and will let us grow with little production deployment pains.

Unfortunately, we will still need to implement the updates in the production environment to make this a reality. No small task if you’re looking at doing this through the IIS manager.

But, let’s not forget that this is a server application, and therefore, should have itself a command line interface. IT DOES! It’s called appcmd, and is found in the %windows%\System32\inetsrv directory. But after doing some research, it looks like it may have some limitations when retrieving the data.

Fortunately, there is another way, and it’s found in the %windows%\System32\inetsrv\config\applicationHost.config file. I will be playing with this more in the next few hours, and so I hope to report some success.

Every time I want to create a new project, I either have to look into previous projects, or go to ConnectionStrings.com. It’s a wonderful site that you can use to find the specific connection string that you may ever need.

For me, however, I typically use 1 of 2 connection strings. It either has a username/password, or it uses integrated security (currently logged in user).

Recently I was tasked with researching connection string best practices, and employing them at the day job. We want a better way to manage all of the connection strings.

I suggested moving the connection strings into the machine.config unencrypted. This will accomplish multiple things.

Centralizes connection strings to one area for all projects residing on that server

Easy to search, maintain, and update since no encryption/decryption is required

“Set it and Forget it” – Deployments to the various environments (DEV, STG, TRN, PRD) won’t need to update connection string after every deployment cycle

But there are some downsides

Need to save across multiple .NET machine.config sourcesThe simple workaround is to keep a configSource file in the root, and utilize a batch file to copy into each frameworks config directory (except 1.1 and below)

Updating a connection string for one project has the potential of disrupting every project on that serverBut I hope you are doing these updates during off hours, so the impact will be minimal.

I will make some mentions of things in this blog that I really hope is not news to anyone. Having your own 2-way hashing/encrypting algorithm will only slow down a hacker. My experience has been that you must “hide” the key, but still reference it. A good file search tool can quickly point to this unlock key to get your connection string. By my estimation, the tool I use can sift through 80 megabytes of data (including text files, images, and binary documents such as PDFs, Word and Excel documents) in less than 8 minutes. Then using a decompiler they can easily get your information.

I was once tasked to take over a project where the previous developer was holding the source code ransom for a bigger bonus. With the awesome experience in programming I had developed over the years, it took me about 45 minutes to get everything I needed into a nice small package. And that was just so I had something pretty to work with, not just mining for anything specific.

I’m sure that if a somewhat experience hacker ever got into your machine, an encrypted connection string is only going to slow him down by maybe 15 minutes, assuming he already has the tools necessary to do his digging. After all, it’s all about the time. If he’s already gained access, knows what he’s looking for, and wasn’t taught the Boy Scout model of “Be Prepared” (even if it’s to be used for evil), the chances of him being caught will be much higher as he’s doing some Google research while breaking into your system.

So, my recommendation is to just keep unencrypted connection strings in the machine.config file(s), as it will save your Operations department many compounding hours in maintenance over the lifetime of the servers.

This post is all about User Acceptance Testing, and why you’ll want a DLL page.

In any good development environment, you’ll want to make sure you have some things covered.
1. Source Control (Source Safe, Vault, Subversion, etc)
2. Documentation Tools
3. Test Plan

With the test plan, you’ll want to mark which DLL you are testing against. That way, you can tell if a release has been updated, or if deployment procedures haven’t been strictly adhered to. Of course, without automatic DLL versioning in the latter part of Visual Studio releases (more on this later), you as the developer will need to make these part of your deployment habits.

In your project, create a DLL.aspx page, and drop the following Grid View source where necessary

Somewhere down the line, a new request was made to make a certain item “plural”. This then caused some unintended consequences of having run-time issues because the string didn’t compare. And let’s not get started on the fact that it’s case sensitive. It’s actually one of the main reasons why I try to utilize enumerations whenever possible… They’re short, simple, and will break if you type it wrong.

Well, due to the issue, I realized I should utilize .NET’s compiler and properties to my advantage. With that, I turned

Case "lnkDivisions"

to

Case lnkDivisions.ID

VOILA. It slices! It dices! It compiles! Make an update to the text and it will still work. Rename the control without updating the case statement, and it will not compile. You are forced to fix it without stumbling across it during User Acceptance Testing.