How to Fix “No ‘Access-Control-Allow-Origin’ header” in ASP.NET WebAPI

I am not 100% sure what Google did to Chromium in Update 42.  However after that update landed I started to get reports of our Angularjs application started to have problems communicating with our ASP.NET WebAPI.  We started getting errors similar to this:

No ‘Access-Control-Allow-Origin’ header is present on the requested resource

Continue reading

Advertisement
Posted in ASP.NET, C#, Web | Tagged | Comments Off on How to Fix “No ‘Access-Control-Allow-Origin’ header” in ASP.NET WebAPI

Remove the Microsoft GitProvider from Visual Studio 2013

If you are like me and use a different git tool that operates outside Visual Studio or as an extension or your frankly tired of the performance hit that this provider causes.  Of course the default solution of setting source control to none did not work for me.  As soon as Visual Studio detected a git repository in my solution it will flip it back on.

Continue reading

Posted in Source Control, Visual Studio | Tagged , , | 4 Comments

Order the controllers in ASP.NET WebAPI Help

Recently I started a new API project for my company.  With this project I decided to give the Help files generator that Microsoft created a try.  Overall it looks like it will meet the needs of the project.  Today however I hit my first snag with it.  After I began to turn on routes for consumption I noticed in the help page that the routes was not sorted in any fashion.  To me, this can cause a level of annoyance for the folks needing to consume this. 

Continue reading

Posted in ASP.NET, C# | Tagged | 4 Comments

Windows 8 How to add Open PowerShell Here to Context menu

I use git-tfs and poshgit on windows.  So when I need to do a check-in I need to open PowerShell, navigate to the location of the project and so on and so forth.  That can get tedious at times, similarly to how users would add  open command window here.

Continue reading

Posted in Windows | Tagged , | Comments Off on Windows 8 How to add Open PowerShell Here to Context menu

Split a PCM Stereo into multiple mono files by channel

For this you can read and write the data streams as you like, to keep things simple I am using NAudio.  This should negate the need to write custom stream readers/writers to get channel/header information. 

First thing we need to do is read the audio file into a byte array.  This can be accomplished like this:

using (var s = new WaveFileReader(@"C:\temp\testStereo.wav"))
{
     BinaryReader br = new BinaryReader(s);
     byte[] data = br.ReadBytes((int)s.Length);
     WriteNewAudioFiles(data, @"C:\Temp\", s.WaveFormat.Channels);
}

Continue reading

Posted in C# | Tagged | Comments Off on Split a PCM Stereo into multiple mono files by channel

BugAid is now OzCode and improved

Back in September 2012 I wrote an article BugAid – C# Visual Studio Debugging made easier . BugAid’s co-founder Omer Reviv has joined forces with CodeValue to produce OzCode.  Base product wise it does everything BugAid did before (read the linked article if you like, and in normal fashion they have added some additions in order to improve it. 

Continue reading

Posted in Debug | Tagged , | Comments Off on BugAid is now OzCode and improved

Move the folder location of Windows Live Writer

For blogging there are a slew of tools and when you find one that works well for you, you tend to stick with it.  For me that tool was Windows Live Writer which is included as part of the windows essential package.  Live writer has a simple installer with one downside.  You have no control in the installer over were the Drafts and Recent Post folders are located.  I like to hold mine in a cloud drive for backup and syncing between all my machines.

Continue reading

Posted in social | Tagged | Comments Off on Move the folder location of Windows Live Writer

How to Unit Test a Private/Protected Method with MSTEST

Note: these steps work for both private and protected methods

Search online or post this question on Stack Overflow and guess what you will get in response most of the time.  

Don’t do it, I repeat Do not unit test private methods

These are 3 of common responses I found online as to why you should not unit test private methods.

Continue reading

Posted in C# | Tagged | Comments Off on How to Unit Test a Private/Protected Method with MSTEST

Older Web applications and the challenge of IE 10+

As the market share of Internet Explorer 10 increases along with the looming release of Internet Explorer 11 a growing number of web developers are realizing that Microsoft in their great wisdom (I am not against it, just wish there was an option) removed the ability to use conditional comments.

In a sense breaking every legacy application that a company might be using.  For those that do not know or need a refresh, conditional comments where a way to do something like this:

Continue reading

Posted in Browser, Web | Tagged | 2 Comments

Battle of the INotifyPropertyChanged techniques

Recently at a conference I was given the opportunity to talk about Aspect Orientated programming with PostSharp.  In my demo I showed off the difference between creating an INotifyPropertyChanged class manually, using boilerplate code generated by Resharper, and using smart tags built into PostSharp 3.  By the request of a few, here is what was covered.

Continue reading

Posted in C#, PostSharp | Tagged , , | 1 Comment