Archives

Archives / 2009 / September
  • Gmail does not allow zip files with executables

    I sent an email with a zip attachment the other day from my Gmail account and I received an Non-Delivery Report (NDR) from Gmail. At first I was very confused because I was purposely sending a zip file to get around any rejection of the attachment (the attachment was a C# development project that I had been working on).

    This is the NDR email that I received:

    From: System Administrator
    Sent: Saturday, September 26, 2009 6:51 AM
    Subject: Undeliverable: Emailing: project.zip
    Your message did not reach some or all of the intended recipients.

    Subject:    Emailing: project.zip
    Sent:    9/26/2009 6:51 AM

    The following recipient(s) cannot be reached:
    'XXXX XXXX' on 9/26/2009 6:51 AM
    552 5.7.0 review our attachment guidelines.

    A quick Google for what was going on turned up the answer: http://mail.google.com/support/bin/answer.py?answer=9481&cbid=-16aiqkfahjlzz&src=cb&lev=answer.

    Gmail does not allow you to send zip attachments with executables in them.  From the Gmail FAQ:

    Gmail allows you to send and receive zipped attachments, as long as they meet three conditions:

    1. They don't contain executable files.
    2. They are less than the maximum attachment size.
    3. They are not encrypted or password-protected AND don't contain other zipped files. If the attachment is encrypted and does not contain another zipped attachment, then it can be sent and received.

    Since I was sending an entire C# application that I had been working on (I just zipped up the parent folder), the bin directory had the compiled exe in it and Gmail picked up on it and rejected the attachment.

    I probably could have just removed the exe from the zip file but I tried sending as a winrar (.rar) attachment and everything worked fine. Just an FYI for anyone out there who tries the same thing but runs into the vague NDR message of "552 5.7.0 review our attachment guidelines".

     

  • Awesome viral marketing video by Freebord

    Check out this awesome video from freebord.com:

    First time I watched this video I thought it was very cool.  Then after watching it the fifth time (because I had to show it to my wife and kids) I thought: how are they skating like that?  So I went to their website: http://www.freebord.com.

    And then I sent the video to a couple other friends and family and tweeted it.  :)

    Like I said… very nice job of viral marketing.

     

    Technorati Tags: ,
  • From IIS6 maxRequestLength to IIS7 maxAllowedContentLengthFile – specifying maximum file upload size

    IIS6 uses the maxRequestLength config setting under the system.web section to specify maximum file upload size with a default of 4 MB.  IIS7 uses the maxAllowedContentLength config setting under the system.webServer section to specify maximum file upload size with a default of 28.6 MB.  This is something to watch out for when migrating your web application from IIS6 to IIS7.  Read on for more information how I found out about this new config setting for IIS7….

    I have migrated several sites from IIS6 to IIS7 without much problems.  One gotcha that I did get caught on is the new IIS7 config settings section (system.webServer) and those settings for specifying the maximum file size to be uploaded to the website.  After migrating a certain web application from IIS6 to IIS7 everything appeared fine until a few customers began complaining about issues when uploading files to the website… in particular these were large files around 50MB.

    In IIS 6.0 there is a config setting (attribute) called maxRequestLength located under the httpRuntime section in system.web that you can use to specify the maximum allowed request length (in other words the maximum uploaded file size).  In IIS 6.0 the default is 4096 which is number of kilobytes allowed… so a 4MB file is the default file upload size under IIS 6.0. 

    A 4MB is pretty small these days so it is quite common to need to override the default and put in a different value here.  For the web application that I was migrating to IIS7, we had increased the maximum file size to 200MB (and told our customers 200MB was the max upload too).  This is what the httpRuntime section was set to:

    <system.web>
        <httpRuntime maxRequestLength="204800" executionTimeout="7200"/>

    So we migrated the web application to IIS7, tested some large file uploads (we tested with 20MB files… note this for later) and everything seemed great.  After rolling the website out to our customers, a couple weeks post release we got a couple complaints about customers not being able to upload files.  Their files were about 50MB in size.

    At first this was puzzling because we clearly had the config setting in place that indicated 200MB was the new limit (or so we thought) AND files larger than 4MB were allowed (we had tested 20MB files).  But we could easily reproduce the customer issue with their 50MB files failing.  So what was going on?

    Eventually we tracked it down to IIS7 and the new config section called system.webServer.  We had known that httpHandlers in IIS7 were now to be specified in the system.webServer/handlers section but what we did not know (and did not find out until our customers ran into it) was that the maximum request length setting for IIS7 is also in a new location.  In IIS7 you specify the maximum size of a file to be uploaded to the website by using the maxAllowedContentLength setting (system.webServer/security/requestFiltering/requestLimits >> maxAllowedContentLength).

    <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="209715200" ></requestLimits>

    Now why didn’t our tests with 20MB files show this?  Because in IIS7 the default value for the maxAllowedContentLength setting is 30000000 and that is in bytes: 30000000 bytes = 28.6 MB.  So in IIS7 the default had increased to 28 MB so we did not notice it since we were testing with only 20 MB files (and assuming the default was 4MB).  In the end we got this resolved fairly quickly and it showed an issue in our testing (we really should have been testing a 200MB file… the limits of what we tell our customers).

     

  • Credit Card Expiration Date ASP.NET MVC SelectList Sample Code

    A couple weeks ago I wrote about how to create credit card expiration date drop downs for your ASP.NET application.  Today I had to do the same thing but in ASP.NET MVC.  For the most part I was able to use the same logic but instead of slowly building up the drop down list items, in ASP.NET MVC I created a SelectList which is constructed from an IEnumerable object containing the collection of items to display. 

    From the MSDN Documentation for SelectList:

    SelectList Constructor (IEnumerable, String, String, Object)
    Initializes a new instance of the SelectList class by using the specified items for the list, the data value field, the data text field, and a selected value.

    In ASP.NET MVC you can use the Html.DropDownList helper to create the dropdownlist from a SelectList object:

    <%= Html.DropDownList("ExpMonth", Model.ExpMonthSelectList)%>
    <%= Html.DropDownList("ExpYear", Model.ExpYearSelectList)%>

    But the problem is what IEnumerable object could I use to contain the month and year information but also has data value and data text parts? This is where the System.Collections.Generic.KeyValuePair structure comes in:

    //Create the credit card expiration month SelectList
    List<KeyValuePair<string, string>> expirationDateMonths = new List<KeyValuePair<string, string>>();
    for (int i = 1; i <= 12; i++)
    {
        DateTime month = new DateTime(2000, i, 1);
        expirationDateMonths.Add(new KeyValuePair<string, string>(month.ToString("MM"), month.ToString("MMM (M)")));
    }
    this.ExpMonthSelectList = new SelectList(expirationDateMonths, "key", "value", DateTime.Today.ToString("MM"));

    //Create the credit card expiration year SelectList (go out 12 years) 
    List<KeyValuePair<string, string>> expirationDateYears = new List<KeyValuePair<string, string>>();
    for (int i = 0; i <= 11; i++)
    {
        String year = (DateTime.Today.Year + i).ToString();
        expirationDateYears.Add(new KeyValuePair<string, string>(year, year));
    }
    this.ExpYearSelectList = new SelectList(expirationDateYears, "key", "value", DateTime.Today.Year.ToString());

     

    Technorati Tags: ,
  • QuickBooks Online Edition (QBOE) Testing Environment

    I am developing an application that will interface with my clients QuickBooks Online Edition (QBOE) database and I need to do unit testing of this application while I am developing.  The end goal of the application is to insert the appropriate journal entry items into their production QuickBooks Online Edition database, so I need to do unit testing of those inserts into a test/development QBOE environment.  

    There is an Intuit Development Network (IDN) testing environment which I figured was the way to go.  But after several days of searching on how to get into the test environment, I eventually found out that you need to get IDN certified which costs money and also takes a good amount time.

    In the end what I did was sign up for my own QuickBooks Online Edition account and created my own fake company.  There is a 30-day free trial and after that it is $9.95/month.  There is a good chance I will be finished with my testing before the 30 day free trial ends but even if I am not, paying $9.95/month for a development tool is perfectly acceptable in my mind too.

    image

    See this IDN thread (Is there a QuickBooks Online Edition test environment?) for a little more details on the IDN certifications if you are interested.  I started this StackOverflow question too but I ended up answering my own question there (not too many StackOverflow QuickBooks users yet.)

     

  • How to Reseed a SQL Server Identity Column

    In SQL Server you can specify a column as an Identity column (ColumnName int IDENTITY(1,1) NOT NULL) to have SQL Server automatically set the value of this column upon insert by incrementing a seed value.  This works great but I have run into situations where I wanted to change what identity value is assigned during the next insert. 

    What had happened is that this table in question had the primary key column set as an Identity column.  There were only a couple thousand rows in the table but SQL Server was handing out identity values in the 10-million range.  In most cases this would not be a big deal, but for this table the identity value was actually used by customers so a eight digit number was not as easy to remember and repeat as a 4-digit number. 

    What had happened is that a row had been inserted into the table with a high identity value (over 10 million) and then SQL Server took over from there and handed out new identity values that were incremented from that number – 23000001, 23000002, 23000003, etc...

    To fix this, I was able to change the seed of the Identity field by using a DBCC CHECKIDENT statement.

    You can use this DBCC CHECKIDENT statement to check the current identity value:

    DBCC CHECKIDENT('table_name', NORESEED)

    And then you can use this DBCC CHECKIDENT statement to change the identity value to another value:

    DBCC CHECKIDENT('table_name', RESEED, 2300)

    After making this change new records inserted into the table now were assigned 4-digit values and were much easier for customers to remember and use.

     

    Technorati Tags: ,
  • BabySmash! And defining what the power button does…

    My son Koah loves to sit on my lap while I am working on my computer.  Usually he is fine to sit and watch the screens change, windows popping up and down, browsers loading, as I did my development work.  But over the past couple of weeks he has gotten much more aggressive and even having some family videos playing on the second monitor would not placate him… he just wants to bang on the keyboard. 

    So this is where I pulled out my old Dell 8200 laptop and installed Scott Hanselman’s BabySmash.  BabySmash is an application written by Scott Hanselman that

    will lock out the Windows Key, as well as Ctrl-Esc and Alt-Tab so your baby can't get out of the application. As babies smash on the keyboard, colored shapes, letters and numbers appear on the screen.

    Koah loved it and had a blast as the letters and shapes appeared and disappeared as he banged on the keyboard.  But Koah being a curious baby, quickly found the power button on the laptop and pressed it.  The laptop shut down, no more BabySmash.

    I had forgotten to disable the power button action that shuts down the computer when it is pressed.  You can do this on Windows Vista under Control Panel > Power Options > Choose what the power button does.  Just change the default setting of “Shut down” to “Do nothing”.

    image

    Of coarse he can still hold the power button down for 5 seconds and the entire machine will shut off... hopefully he will not be able to figure that out.

     

    Technorati Tags:
  • StackOverflow Stickers

    I got my StackOverflow, ServerFault, SuperUser, and How-To Geek stickers from Jeff Atwood yesterday (In stickers We Trust).  They are really nice looking.

    IMG_7645

    In case you have not heard of StackOverflow it is the most awesome question and answer site (100% free!) for developer related questions.  ServerFault is for sysadmin questions and SuperUser is for general computer questions that really do not fit into the other two sites.  How-To Geek is a partner of all three.

    Now I have to go talk to my wife about putting these on the bumper of the car… she’s got her MOPS sticker there, so why not StackOverflow too?!?

     

    Technorati Tags:
  • Credit Card Expiration Date DropDownList Sample Code

    The other day I needed to create a credit card input form including the drop down lists for the credit card expiration month and year.  I started to write the code to populate the month and year drop down lists and I wanted to make them dynamic so that whatever the year was it would add an appropriate number of list items.  But as I started thinking about how to structure the code, I figured that this has been written probably thousands of times by other developers so I would just Google for it.  To my surprise, I was unable to pull back any sample code for my various search terms.  In the end I had to write it myself but now I am posting it on my blog so that others my benefit from my hard work.  :)

    //Populate the credit card expiration month drop down
    for (int i = 1; i <= 12; i++)
    {
        DateTime month = new DateTime(2000, i, 1);
        ListItem li = new ListItem(month.ToString("MMM (M)"), month.ToString("MM"));
        ExpirationDateMonthDropDown.Items.Add(li);
    }
    ExpirationDateMonthDropDown.Items[0].Selected = true;

    //Populate the credit card expiration year drop down (go out 12 years) 
    for (int i = 0; i <= 11; i++)
    {
        String year = (DateTime.Today.Year + i).ToString();
        ListItem li = new ListItem(year, year);
        ExpirationDateYearDropDown.Items.Add(li);
    }
    ExpirationDateYearDropDown.Items[0].Selected = true;

     

    Technorati Tags:

  • How to get the mouse wheel to work in VB6 IDE

    Visual Basic 6.0 (VB6) applications are still around and frequently I will have to work on some Visual Basic 6 COM Component DLL or application.   I would much rather prefer to work in c# or VB.NET but I completely understand a companies decision to not rewrite a reliable VB6 component but prefer to just make minor changes to it (especially when they have limited resources and the VB6 component does not provide value add to the customer). 

    So I have no problem working with Visual Basic 6 except for one of the most painful parts which is no mouse wheel support in the code window.  It sounds like just a minor inconvenience but in reality not having mouse wheel support slows down development dramatically when trying to find your way around some VB6 code.

    I was about to post my question on StackOverflow but as soon as I typed in my question this StackOverflow question popped up with the #1 answer pointing me to this Microsoft Support article for a Mouse Wheel Add-in for VB6: 

    Mouse wheel events do not work in the Visual Basic 6.0 IDE - http://support.microsoft.com/kb/837910

    Follow the instructions in Method 1 described on that page and then your mouse wheel will work within the Visual Basic 6.0 IDE code window.  Very, very nice!

    Technorati Tags: ,
  • PureText is Pure Gold!

    PureText from Steve Miller is a very simple and extremely useful utility that makes the Windows-V hot key combination paste non-formatted text instead of formatted text. 

    image

    I use it all over the place and I make sure it is installed and set to run at startup on all of my machines including my wife’s laptop.

    From the PureText website:

    PureText is basically equivalent to opening Notepad, doing a PASTE, followed by a SELECT-ALL, and then a COPY.  The benefit of PureText is performing all these actions with a single Hot-Key and having the result pasted into the current window automatically.

    By the way, guess how I pasted in the text above that I copied from the PureText website?  :)

     

    Technorati Tags:
  • How to reset an Outlook view – expand all groups

    For some reason one of my Outlook folder’s views ended in a state where the groups were always collapsed.  It was not a huge deal but just annoying enough to bug me.

    image

    I tried several things to get it to stay expanded but I could not find the setting to change the view to always be expanded and stay expanded when I left the folder and returned.

    Eventually I figured out that I could just reset the current view to the original settings to resolve the problem.

    To do this, first browse to the folder with the view problem.  Then go to View > Current View > Customize Current View…

    image

    In this dialog there will be a Reset Current View button on the bottom right.  Click this button and then click OK. 

    image

    Now you view will be back to the default which is to have all groups expanded.

  • Import RSS Feeds to New Outlook Profile from Common Feeds List

    I am in the process of migrating from one Outlook profile to a new one (I am actually moving away from Exchange and back to the .pst world).  Initially I created a new profile, created a data file, and then added my email account to POP email into the new data file.  All done… nice and easy… time to turn off the lights and go home.  Hang on a second… where are my RSS Feeds?

    I use Outlook to download my RSS Feeds and I have several that I enjoy reading and now my new profile does not have those RSS Feeds listed.  Luckily I was able to find two solutions to get those feeds over to me new profile.

    First, I could export the feeds from my old Exchange profile as an OPML file and then import them into my new Outlook Profile.  This can all be done from Outlooks File menu using the Import and Export Wizard.

    This would have been easy enough but there was an even easier way for me.  I added my RSS Feeds into the Common Feed List through Internet Explorer and there is an option to import the RSS Feeds from the Common Feed List.

    image

    Select this option, choose next and you will be presented with a list of RSS Feeds that you can check or uncheck for import into Outlook.  Now I have my new Outlook Profile set up just like my old one when I was on Exchange.

  • BurnCDCC – Burn ISO files to DVD

    One of my tools that I keep in my \Utils folders and use often is BurnCDCC.  As described on the TeraByte website BurnCDCC will burn an ISO file to a CD/DVD/BD disc.

    image

    The freeware download is just a zip file containing an EXE that just runs… that’s right no install necessary.  Running BurnCDCC.exe gives you a simple and easy to use user interface.  Select your ISO file, check a couple of options, choose your DVD drive, and hit start… and it just works.  Perfect for burning those Windows 7 and Windows Server 2008 R2 ISO images to DVD.

    image

    Technorati Tags: ,
  • Index Server and the Enable 32-Bit Applications Setting

    We had a old website that made use of Microsoft Index Server and the Index Server COM objects (ixsso,Query).  Everything was working fine on our Windows Server 2003 machines under IIS6. Then when we migrated to Windows Server 2008 and IIS7 our classic asp pages (which we did a straight migration over to classic asp in IIS7) could not instantiate the Index Server objects.

    Simply instantiating the object would fail:

    Dim objQuery  
    Set objQuery = Server.CreateObject("ixsso.Query")

    After a call to Microsoft PSS we were finally able to track down the problem to the Application Pool running in 32-bit mode.  IIS7 allows you to run the application mode in 32-bit or 64-bit by configuring this setting of the application pool:

    image

    False is the default but it was overridden to true in the Application Pool where the Index Server object was being instantiated.  And the Index Server dlls are 64-bit only.  So while a 32-bit dll can load in a 64-bit process the reverse is not possible.  There was no reason that the application pool was set to 32-bit so we switched it to 64-bit (changed the “Enable 32-bit Applications setting to false) and everything worked.