ASP.NET MVC 3 Redirect Query String with id

This tip is mostly because I’ve run into this issue a few times and keep forgetting what I did. The tip concerns an ASP.NET MVC 3 Query string property for redirect using the key ‘id’ when you have a route defined that uses ‘id’ as such:


And you want to redirect to:

You also want to keep that id query string because it is a string value that can be a GUID or some string or even an integer. Yes I realize this is bad design but I was working on something out of my control.

The way to accomplish this is to use this:

Redirect(Url.Action("Action", "Controller") + "?id=" + id);

Instead of:

return RedirectToAction(“Action”, “Controller”, new { id = idvalue });

When you use RedirectToAction, it will format your url and remove the querystring which you want to keep. By using Redirect and forging the query string yourself, you get to keep the ‘?id’ part in the URL.

Tagged , , ,

Brand New Day

We all make list of things we wish to do and I have some that I keep with me. One of my bosses once told me how he kept a list in his wallet at all times and would modify and tweak that list weekly to help him achieve his goals. Since then I have started doing that too. It’s a big piece of paper duct taped to the wall in front of my main machine at home (most because I already have too many bits of pieces of paper in my wallet and don’t need another one to sit on). I’ve revised it for the new year and one of the things I aim to do this year is be more active about Node.js & Windows Azure. To that end,

  • I’ve started following smarter (than me!) people on twitter
  • I’ve decided to move my blog to Azure (as soon as I figure out how!)
  • I will learn by going through the Azure SDK for Node
  • I will link to items I find interesting about Node.js and Azure daily (weekly?)
  • I will tweet about Node.js and Azure as well (or RT as the case may be)

What will you do this year?

Tagged , , , , , ,

An IoC Conundrum: Looking for feedback

Today at work, my boss and I were brainstorming on the best way to use IoC across all our code. During this, he proposed an idea for using IoC that at first made me feel uneasy with the way it was being used. But the more I think about it, the more I am amazed by its design. Let me set this up for you and the best way is with pictures.

Note: The code examples given here are not functional and just provided to give a rough idea of what is intended.


  • The BaseLib is a library that contains all the interfaces we define. It also contains the CDepInjection class.
  • The CDepInjection class contains a static Register method that will find an assembly that corresponds to an interface and using Reflection, load it.
  • The Database library contains a CDatabase class with a static constructor that will be called from the previous step when the Database library is reflected and loaded. See image below.


  • By having all the interfaced in BaseLib, we are programming against an interface.
  • By having the CDepInjection class in BaseLib, there is only 1 place we need to update code and only 1 dll that we will need to deploy in production should changes be needed. (Note: We could have 100 servers running 100 application each and they may be windows services, web services, mvc apps, windows forms apps, console apps etc.).
  • By making a change in CDepInjection and telling it to map an interface name to the appropriate assembly and class and having the RegisterType be in the CDatabase class, we can create a new database class, CNoSqlDatabase in another assembly, deploy it, make a change to BaseLib by telling it to now map IDatabase to the CNoSqlDatabase and then deploy that to all our servers GAC. Now, everything will use the new CNoSQLDatabase.

Concerns I have:

  • Using a static constructor in CDatabase means that it will be called one per process and only when the assembly is loaded in the Register(..) method of CDepInjection. I’m not convinced that a static constructor would be the best thing to do. In essence, aren’t we just abstracting the mappings that would go in a config file and putting them into BaseLib instead of an app.config of BaseLib?
  • Resolving parent-child would necessitate having to call register in the ‘main’ method of all our applications. For instance, if CDatabase was going to need logging, it would have to call Register(“ILogging”) in the static constructor above the Container.RegisterType<IDatabase, CDatabase>() call.

I would very much appreciate a critique of this design. Thank you.

Tagged , , , , , , , ,

Standing Desk for Tall People and Multiple Monitors

I’m a tall person and like many developers, I sit. A lot. I’ve been feeling a pain in my back for some time now and I’m determined to do something about it. As usual Scott Hanselman has already been there and done it for you. Buy this man a beer and find a way to keep him alive. He’s our Obi-Wan. OK! Enough gushing.

  1. Exercise. I plan to work out 3 times a week during lunch so as to strengthen my core.
  2. Eating. I already eat health. I weight myself everyday, allowing for slight variations that tend to occur. The idea is to notice any drastic changes. I lost 15 pounds in 1 month due to a thyroid storm but luckily it was temporary.
  3. Standing and Posture. Sitting, hunched over at ill fitting desks and chairs has been my undoing. There have been lots of studies and developers talking about how switching from sitting to standing has helped them so I won’t bore you with the details. Needless to say, tall people are SOL when it comes to office furniture (unless you happen to work at a very nice company that makes an effort to adhere to ergonomic standards).

Did I mention I code? That’s important because we’re inherently lazy (hence the back pain). So, I researched some standing desks. Then I researched some that would fit me. Geekdesk has really nice desks and I was willing to splurge on a desk but waiting 6-7 weeks for it to ship and then paying 300+ on shipping is just not worth it.

Did I mention I’m lazy? That’s important. Because laziness breeds invention. Over my lunch break today, I finally had enough of my back pain and decided to just make my standing desk, even if it is just boxes stacked together in Jenga form. I walked around the house and found 2 things that could immediately help me.

  1. Expedit Workstation –
  2. Lack Coffee Table –

Stack these two together and you get a standing desk that works for a tall person (> 6′ 4″). Benefits include:

  • Simple
  • Works for tall people
  • No carpentry required
  • No separate keyboard tray necessary
  • No furniture destroyed (easy to put the coffee table back when guests come)
  • Supports Dual Monitors (multiple monitors is the only way to work and any solution you use should utilize this)

Standing Desk For Tall people with Multiple Monitors
This is what the result looks like. The laptop is below the desk and makes it easier to sit down when I need a few minutes to rest. I do hope you get to utilize this multi monitor solution. If you’re still hell bent on carpentry and building, take a look at the IKEA Hackers page.

//ToDo Look into getting some cushioning for the feet. I used a yoga mat today and it felt great. Only problem is that my feet started sticking on the mat after an hour. Donn Felker recommended the GelPro mat in one of his tweets and I might need to look into that too.

Tagged , , , , , , , ,

DbComparer o_O

tl;dr: Don’t install DBComparer because it may install crapware for you.

Last week, I needed to use a SQL SERVER 2008 database compare tool for work. After searching for clues on Stackoverflow, I decided to give DBComparer a try! I am generally a very careful person on what I install and I remember having used this tool before so I gave it another go. I distinctly remember telling it to NOT install the babylon toolbar on my machine. Few days later, I installed SSMS Tool Pack.

Then, I started noticing that my machine was slowing down. All of a sudden, my search defaults were changed to babylon. I uninstalled the extensions from chrome, reset the search defaults and continued on my way. The machine continued to crawl. I had an SSD on there and opening a simple txt file would take 5 seconds when normally it would take less than 1. I immediately uninstalled SSMS Tool Pack thinking it was the culprit but even that didn’t help. I ended up having to wipe the machine. Completely. The SSD is now sitting on my desk.

Today, I asked the author of SSMS Tools Pack, Mladen Prajdic about babylon in his installer. He quickly pointed out that his tool pack does not use it. I installed his tool pack and no Babylon. And I apologized for rushing to judgement.

Twitter Conversation with Mladen Prajdic


So I dug around a bit more and came up with what I found to be the culprit. I’m not sure if its intentional on DBComparer’s part but they really should take that crapware off! I am a little pissed off about this. See highlighted at the bottom on the image. [Google Cache Source of image]

Bablyon installs with DbComparer

To reiterate, it says “…we may show optional offers, such as the Babylon Toolbar.” Now, I did download the installer for the DbCompare site directly. Did they add it in?


Tagged , , , , ,