Jeff Widmer's Blog
ASP.NET, ASP.NET MVC, C#, VB.NET, IIS7, Windows Forms, VB6, ASP 3.0
-
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:
- They don't contain executable files.
- They are less than the maximum attachment size.
- 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".
Technorati Tags: Gmail 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: Freebord,Viral Marketing -
Stack Overflow Profile
-
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: ASP.NET MVC,C# Sample Code -
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.
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.)
-
Random numbers and where to get them
Ever need to randomize a list of items quickly? Then check out http://www.random.org. It can generate random numbers, lists of numbers, sequences, and much more. The one I use the most is the Random Sequence Generator. Comes in very handy when you need to randomly choose the order of a group of people.
Here is Random Sequence Generator in action. Enjoy!
-
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: SQL Server,SQL -
I Love StackOverflow!
Question: Should I use nvarchar(max) in place of a nvarchar(64) column or as an additional column?
First answer in 7 minutes. Completely detailed answer that thoroughly expanded my knowledge and now I feel like I have the best solution: 46 minutes. Amazing!
Technorati Tags: StackOverflow -
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”.
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: BabySmash