MIME Type for .MP4 files is video/mp4
I almost made a mistake and put the wrong MIME Type into IIS7 for some MP4 videos that I am serving from a web server. A search for “MP4 mime type” returns two different results:
- video/mp4 (correct)
video/mpeg (not correct)
I was not so sure if there was a difference (although most results did lean toward video/mp4, there were a good number of video/mpeg recommendations out there to make me question the correct one).
To resolve the issue I tried both in IIS7 and Chrome.
For video/mp4 Chrome will give you the HTML5 video player (a very nice user experience):
For video/mpeg Chrome will launch QuickTime... blah!
I didn’t test any other browsers... this was proof enough for me that video/mp4 is the correct MIME type of .MP4 files.
Technorati Tags: IIS7
How to disable an ASP.NET linkbutton when clicked
MyButton.Attributes.Add("onclick", "this.href='#';this.disabled=true;" + Page.ClientScript.GetPostBackEventReference(MyButton, "").ToString());
With the code above now the button onclick event will look something like this:
The anchor href is set to “#”, the linkbutton is disabled, AND then the button post back method is called.
Visual Studio Shortcut: Surround With
I learned a new Visual Studio keyboard shortcut today that is really awesome; the “Surround With” shortcut.
You can trigger the Surround With context menu by pressing the Ctrl-K, Ctrl-S key combination when on a line of code.
Ctrl-K, Ctrl-S means to hold down the Control key and then press K and then while still holding down the Control key press S.
Here is where this comes in handy:
You type a line of code and then realize you need to put it within an if statement block. So you type “if” and hit tab twice to insert the if statement code snippet. Then you highlight the previous line of code that you typed, and then either drag and drop it into the if-then block or cut and paste it. That is not too bad but it is a lot of extra key clicks and mouse moves.
Now try the same with the Surround With keyboard shortcut. Just highlight that line of code that you just typed and press Ctrl-K, Ctrl-S and choose the if statement code snippet, hit tab, and POW!... you are done! No more code moving/indenting required.
Here is what the Surround With context menu looks like:
Just up or down arrow inside the drop down list to the code snippet that you want to surround your currently selected text with. Did I mention this is AWESOME!
Now it is so simple to surround lines of code with an if-then block or a try-catch-finally block... things that usually took several key clicks and maybe one or two mouse moves.
And this works in both Visual Studio 2008 and Visual Studio 2010 which means it has been around for a long time and I never knew about it.