Thursday, July 23, 2015

WebDAV error "HTTP Error 405.0 - Method Not Allowed" using WebAPI

This morning I ran into this error on our .Net WebAPI project:

 "HTTP Error 405.0 - Method Not Allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used."
"This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request."

This is after we did the excellent fix suggested at http://evolutionarydeveloper.blogspot.com/2012/07/method-not-allowed-405-on-iis7-website.html.

The problem turned out not to be that the handler was not configured to handle a GET, but that my routing was ambiguous. I edited WebApiConfig.cs and modified the routing to be more specific. Now it works like magic.

(Note to Microsoft: Not to be whiny, but would it be so hard to give us an error like, "ambiguous route"?).

Monday, July 13, 2015

Photos from Austin .Net Users Group July 13, 2015

David McCarter talked to 55 people about 10 things to do to improve your code. David has many years of experience so it was interesting to hear his thoughts.
His contacts:: website: dotNetTips.com, email: dotNetDave@live.com, twitter: @realdonetdave

His tips for writing good code:
* Layer your code. Typical layers: Data, Business, Communications, UI
* Design for occasional internet connection. Why can't I post on Facebook when I don't have a connection?
* Make your app faster. Cache long running reports, use cloud based region data centers. Make "chunky not chatty" calls over the net. (Visual Studio 2015 will make performance issue better)
* Most of your code should be in portable dlls. Only code in client app loads data and interacts with the user.
* Check out IntelliTests in VS 2015.
* 3 Pillars of Object Oriented Programming: Encapsulation, Inheritance, Polymorphism
* Only application should log errors, not the dlls.
* Exceptions and Event Logging. His open source logging utility to fix the problems in .Net's trace logging: dotNetTips.Utility.Logging. Log Severity, Category, CLR version, free physical memory, virtual, OS.
* Internationalization string birthDate = p1.BirthDate.ToString(CultureInfo.CurrentCulture);
* Introduction to Localization and Globalization in .NET by Jeremy Clark on pluralsight.com
* Store format string in Properties.Resources.UserInfoFormat "birthday:{0}, name: {1}"
* Use Strong Naming to prevent spoofing
* David Recommends CodeItRight which finds and fixes errors.
* Use code obsfication, but not the free microsoft one, but buy a commercial obsficator.
* Stop the copy and paste nightmare
* Use code analysis e.g., FXCop
* Use application profiling for memory and performance