Saturday, June 19, 2010

Request.Params == QueryString + Form + ServerVariables + Cookies

I'm doing some work with the ASP.NET Request object and have just discovered that I can get all of the "params" from one property on the Request object.

If I'm not already in a context where the Request object is a member of that context (such as an MVC Controller or a codebehind page) then I will usually access the Request object through the HttpContext.Current object. I always wrap this access in a double are-you-null before trying to access it:

if (HttpContext.Current != null && HttpContext.Current.Request != null)
{
}

These four objects:

HttpContext.Current.Request.QueryString
HttpContext.Current.Request.Form
HttpContext.Current.Request.ServerVariables
HttpContext.Current.Request.Cookies

Can be accessed through a single collection if you reference the:

HttpContext.Current.Request.Params

which gets a combined collection of the other four.

 

Thursday, June 10, 2010

Google home page has images




I noticed this morning that Google has take a leaf from the Bing book and added images as a background to their home page. I think this is great as the images are always fascinating and high quality. However, the one thing that irks me with both Google and Bing home page images is that there doesn't appear to be an easy way to find out where the picture was taken. I would love to know where this was taken, but it may always be a mystery to me unless someone posts a comment here letting me know the source.

Wednesday, June 2, 2010

Upgrading Silverlight project from v2 to v3 (with .NET 4 and MVC2)

I have a setup a site for Online Calculators that I created about 2 years ago to get up-to-speed on Silverlight 2. I've been going through and converting all of my web sites to VS2010, MVC 2, .NET 4, and jQuery 1.4.1.

I anticipated that the calculators were going to be a bit difficult because I'd also included some Codeplex Silverlight Futures (or whatever it was called) charting libraries in the original project and because I was also upgrading the hosting site from .NET 2.0 to .NET 4.0 and well as MVC1 to 2.

I was very impressed with the ease of the upgrade. The VS2010 wizard did it all and it probably took me less that half an hour to complete everything from end to end including setting up the web site on a new server.

The part that I was most concerned with were the charts in the Mortgage Calculator because of the origin (Codeplex) of the libraries and that they may have changed for Silverlight 3. However those went swimmingly. The host site is very basic and so the conversion to .NET 4 and MVC 2 was not a great challenge for the wizard.

Monday, May 24, 2010

Google TV and Advertising Commercials

I was pretty excited when I watched the Google TV announcement last week.

Today I read a couple of commentaries about it and they went on about the features etc. but nobody mentioned the advertising. This surprised me as my initial guess is the reason that Google have entered this market is to gain more surface area for their advertising machine. In my opinion this is great news for all of us.

Everybody complains about the commercial breaks and if you ask someone with a Tivo why they like it they almost always tell you it's because they can fast forward through the commercials. If we don't have commercials then there's not going to be anyone to pay for the movies that we watch. That means smaller budgets for the studios and lower quality for us. We have to have adverts or we will end up moving to a subscription based viewing platform such as Netflix and that might kill off competition for great series and movies and lower the quality as well.

The perfect compromise is show commercials that you want to see. This, I believe, can be achieved with Google TV. By registering yourself and your interests on your device you make it easy for Google (or whatever content provider) to target you with relevant adverts. If I'm in the market to buy a car then I can change my profile settings to reflect that. I can give them my location, price range and model types and dealers in my area can then show ads to me during the breaks. The local dealers aren't going to pay much for that ad space because it will only be delivered to a few people like myself who are in the market for their product. National campaigns probably hit deaf ears 95% of the time. Targeted campaigns should be hitting willing-to-buy consumers 100% of the time. In reality this will of course be lower because there will also be car enthusiasts etc. who will be tuned into that type of ad because of their fanatical nature.

Once you have bought your car and are no longer in the market for one you can change your profile and pick something else that interests you. The question "how do we get consumers to change and/or set their profiles?" then arises. Again, this is easy. Constantly remind them that if they want to see adverts about products that interest them then they should update their profiles.

 

Friday, May 21, 2010

Dropbox File Synchronization

I've been using DropBox for a couple of months now and I'm very impressed. I keep my crucial source code files on there and sleep well at night knowing that they are backed up "off-site." That was my primary goal in using DropBox. However, now, I'm using more of the features and I'm using it to keep my DEV server synchronized with my PROD server with respect to files that have been uploaded by users. This has always been a pain for me to do but now it happens automatically. I've also started investigating the possibility of using it for Continuous Integration in a Cruise Control build environment. I haven't set that up yet but I don't see any reason why that wouldn't work.

Thursday, May 13, 2010

Identify duplicate IP address use to the public

The Domain

You have a website that allows the public to add comments.

For example

  1. You have a forum that users can post to.
  2. You have a product listing that visitors can post reviews against.
  3. Any other listing that the public can comment on that would allow shills to manipulate public opinion for or against a topic/product.

The Problem

Public comments can appear to be from multiple independent sources when in fact they are the same person posting multiple times under different user name's or email addresses.

A Solution

Changing your email address is easy. But posting from multiple different IP addresses is more difficult. One solution to the problem is displaying the user's IP address next to each posting. However, this is often considered non-acceptable as IP addresses are sometimes considered private.

You could generate an image for each unique IP address and display that. This would allow people reading comments to link together identical IP images and know that the comments came from the same source. This is fairly easily done by using Gravatar. You can pick any domain to base your naming convention on, Gravatar doesn't care. Let's use example.com. If two visitors used the same IP address of say 96.125.6.87 then you would generate a fake email of 96.125.6.87@example.com and use the Gravatar algorithm to generate an image URL and display this as an image next to the post. This protects the exposure of the IP address to the public on your web page.

This would have the added benefit of also allowing users (or Admins) to quickly visually spot identical IP addresses being used. If you were serious about this though you would probably just write an admin report that picks out duplicate IP addresses on pages.

Friday, April 30, 2010

VS2010 "cannot create the window"

I installed the release-to-market (RTM) version of Visual Studio 2010 and it worked well for a few days and then suddenly it started giving me a "cannot create the window" error and refused to start.

I did a whole bunch of searching and discovered that there were some incompatibilities with Office 2010 beta (an incompatible DLL) that was causing most of the problems. Not in my case though because I'd never installed Office 2010. If, however, you are reading this and you have installed a version of Office 2010 then you might want to search further as that might be your problem.

I contacted the developers at Microsoft and they were outstanding in the help that they provided me. I downloaded a debugger and created some memory dumps of what was happening in VS2010 when it started and sent them off to Microsoft. They isolated that the problem was happening when the machine.config file was being loaded. I know that I had edited my machine.config and so I became suspicious of my edit.

A quick aside about machine.config's. On a 32-bit operating system with .NET 2 installed there's only one machine.config and that usually lives here:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG

If you have installed VS2010 then that means that you have also installed .NET 4 so there's another machine.config for .NET 4 and you can find that here:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
(On my machine this is the one that VS2010 is using even though I'm running Windows 7 x64.)

If you have a 64-bit OS then you have 64-bit versions of these machine.config's as well taking the total to four. These can be found here:

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config

(I don't know why one is in capitals and the other in proper case.)

An analysis of my machine.config's (all 4 of them) showed that I have incorrectly edited 2 of them. I had added a new section to the machine.config but had failed to add that section name to the sectionGroup. So I was missing this part of the machine.config:

<sectionGroup name="myNewSectionGroupName" ... > <section ...> </sectionGroup>

Which goes inside the <configSections> ... </configSections> part of the file.

In the end it was a PIBKAC* and not a VS2010 bug.

*PIBKAC = Problem Is Between Keyboard And Chair