Posts

Showing posts from February, 2013

DateTimeParser for date strings with characters not supported in C# or .NET

This is an updated version of code I found online: http://chopapp.com/#tkn6endn I needed it to handle stuff like EST, PST, CST, MST and EDT. This can handle even more codes.

Using Windows Azure CDN to store static files for a website

I worked all night yesterday to get this working for my site. Turns out there are multiple issues you have to remember and work out for all of it to work properly. 1. Write a program which will upload your folder structure to BLOB storage. 2. This program should also set the proper content types for different types of files. For ex; if you do not set proper content type to a CSS file your sites CSS file will not load on any modern browser. This is why you will search high and low for cross domain CSS file in Azure CDN not rendering on browser. 3. There is some security setting which prevents cross domain CSS files from loading on a web site. This means you have to be able to go to the correct target page on the Azure CDN from a subdomain of your domain name. Ex: if you host the site on xyz.com, your CSS cannot come from abc.com, but it can come from abx.xyz.com 4. To do this you have to enable custom domain on the azure storage. http://www.windowsazure.com/en-us/develop/n

C# to upload contents of a folder including sub folders to Windows Azure Blob Storage

This is useful if you want to upload stuff like what you would do with an FTP linked to an IIS site: using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.StorageClient; using Microsoft.WindowsAzure.ServiceRuntime; namespace TestConsoleApp {     class Program     {         private static CloudBlobContainer _blobContainer = null;         private static CloudBlobClient _blobClient = null;         private static CloudStorageAccount _cloudStorageAccount = null;         static void Main(string[] args)         {             _cloudStorageAccount = CloudStorageAccount.Parse("KEY");             _blobClient = _cloudStorageAccount.CreateCloudBlobClient();             _blobContainer = _blobClient.GetContainerReference("cdn");             Console.WriteLine("Connected to Azure...");             FileInfo[] files = (new DirectoryInfo(&q

Redirecting to Azure URL from DiscountASP.Net DNS

Their customer support took a long time to reply, made me go in circles and finally gave me a link, then I figured out what to do. " You'll need to use the URL Rewrite module to achieve your idea. You will create a rule within your web.config to redirect any traffic requests to "(www.)xyz.com" to be sent to xyz.cloudapp.net. Update your web.config file or connect via IIS manager to create this rule ( http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module ) " First you have to install an IIS extension which allows you to use your IIS manager (even Windows 8) to talk to their IIS. http://www.iis.net/downloads/microsoft/iis-manager It will download and execute an integrated installer which will install the extension. Then you connect to DiscountASP.net using the below instructions: https://support.discountasp.net/KB/a400/how-to-connect-to-windows-2008iis-7-using-microsoft.aspx Once you connect, it will ask you whether to

Quick AzureQueueManager

using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.StorageClient; using Microsoft.WindowsAzure.ServiceRuntime; public enum QueueNameCategory     {         UnSpecified = 0,         A= 1,         B= 2,         C= 3,         D= 4,         E= 5     }     public class AzureQueueManager     {         private static Dictionary<QueueNameCategory, CloudQueue> _queueLookUp = new Dictionary<QueueNameCategory,CloudQueue>();                 private static CloudQueueClient _queueClient = null;         private static CloudStorageAccount _cloudStorageAccount = null;         private static bool _initialized = false;         static AzureQueueManager()         {             try             {                 _cloudStorageAccount = CloudStorageAccount.Parse("XYZ");                 _queueClient = _cloudStorageAccount.CreateCloudQueueClient();                 CloudQueue queue = _queueClient.GetQueueReference("queue1");                 qu

Right Click Create Unit Test Option gone in VS 2012

http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/f76aafa9-3ea8-4ff3-940d-0dcf3bb70273 Really sad to know this.

Upgrading to Windows Server 2012 Hyper-V

I recently had the oppurtunity to do this. Things to note: 1. Export the VMs and before exporting specify memory as static. 2. Upgrade takes a long time and reboots several times. 3. Before importing the VMs go to the Virtual Switch manager and configure an external network. 4. Importing the VMs take a long time. 5. Be sure to upgrade the integration services on all the VMs.

Download VS 2012 Remote Debugger

http://www.microsoft.com/en-us/download/details.aspx?id=30674 This is most useful. The link does not show up right away in Google at present.

Circular references when there really isn't any?

This link saved me a week of frustration today: http://nobodylikesasmartass.wordpress.com/2009/06/04/visual-studio-circular-dependency-nonsense/ Hail Google!

Fixes to touch support in Javascript

I have been using the code from the below URL to provide swipe events from javascript: http://padilicious.com/code/touchevents/ For some reason, it has stopped working for iOS. I had to painfully fix the code which determines the swipe direction: function determineSwipeDirection() {     if ((swipeAngle <= 46) && (swipeAngle >= 0)) {         swipeDirection = 'left';         //alert(swipeAngle + "-left");     } else if ((swipeAngle <= 360) && (swipeAngle >= 352)) {         swipeDirection = 'left';         //alert(swipeAngle + "-left");     } else if ((swipeAngle >= 158) && (swipeAngle <= 213)) {         swipeDirection = 'right';         //alert(swipeAngle + "-right");     } else if ((swipeAngle >= 45) && (swipeAngle <= 135)) {         swipeDirection = 'down';         //alert(swipeAngle + "-down");     } else {         swipeDirection = '