Saturday, October 25, 2014

Microsoft OWIN: Getting base path for web services (C#)

In my recent post on using OWIN and WebApi, I described how to separate your controllers into a separate DLL. Often the controllers need to call other methods that may need access to the base path of the web service (e.g. the bin folder).

The code below can be used to find that base path from other classes, without having to always pass a path parameter from method to method.

Thursday, October 23, 2014

OWIN hosting using a Separate WebApi Controller DLL

Here is a bare bones demonstration (4 minutes) showing you how to create a standalone class library of a WebApi controller, then hosting the controller in Microsoft's OWIN (in IIS). This is done using Visual Studio 2013 Update 3.

The video can be watched here: YouTube Watch

The source can be downloaded here: Download Source

What do you think?

Sunday, October 12, 2014

WeightedRandom - Select content based on weights (C# / .NET)

Need to select content from a collection based on weights?  Here is a great .NET 4+ class that is very helpful.

The class can be used with just about any collection and you can pass in a delegate/lamda to determine what the weight is on each collection object.

Tuesday, September 2, 2014

Moving a ClickOnce deployment to another URL/domain

Here is a good video post by Robin on how to move a Microsoft ClickOnce application to another URL (either on the same domain or on a brand new domain).  This process worked very well.

Moving a ClickOnce application (video)

Monday, February 24, 2014

New features in MVC versions (MVC 3 vs. MVC 4 vs. MVC 5)

ASP.NET MVC 3
  • New Project Templates having support for HTML 5 and CSS 3.
  • Improved Model validation.
  • Razor View Engine introduced with a bundle of new features.
  • Having support for Multiple View Engines i.e. Web Forms view engine, Razor or open source.
  • Controller improvements like ViewBag property and ActionResults Types etc.
  • Unobtrusive JavaScript approach.
  • Improved Dependency Injection with new IDependencyResolver.
  • Partial page output caching.

ASP.NET MVC 4
  • ASP.NET Web API, a framework that simplifies the creation of HTTP services and serving a wide range of clients.
  • Adaptive rendering and other look-n-feel improvements to Default Project Templates.
  • A truly Empty Project Template.
  • Based on jQuery Mobile, new Mobile Project Template introduced.
  • Support for adding controller to other project folders also.
  • Task Support for Asynchronous Controllers.
  • Controlling Bundling and Minification through web.config.
  • Support for OAuth and OpenID logins using DotNetOpenAuth library.
  • Support for Windows Azure SDK 1.6 and new releases.

ASP.NET MVC 5
  • Bootstrap replaced the default MVC template.
  • ASP.NET Identity for authentication and identity management.
  • Authentication Filters for authenticating user by custom or third-party authentication provider.
  • With the help of Filter overrides, we can now override filters on a method or controller.
  • Attribute Routing is now integrated into MVC 5.

Source: http://www.webdevelopmenthelp.net/2014/02/ASP.NET-MVC3-Vs-MVC4-Vs-MVC5.html

Sunday, February 23, 2014

ASP.NET: Web Forms vs. MVC (how to decide)

Why ASP.NET Web Forms and Why ASP.NET MVC?

Each can be the “best choice” for a particular solution depending on the requirements of the application and the background of the team members involved. What to choose and when has more to do with business prospective than which one is better than other. When facing a decision to choose between ASP.NET Web Forms or ASP.NET MVC it is important to know that neither technology is meant to replace the other.

Two important factors you should consider while making the choice is:
  1. Rapid application development - If you want to develop anything rapidly ASP.NET Web Forms is the only chance you are having, you can’t even consider for ASP.NET MVC for RAD. (Reasons for RAD may be anything like client is not paying too much, or application is going to be used for only one or two months and won’t require much maintenance.)
  2. Unit Testing - If automatic unit testing is most important factor for you MVC will be best for you.
Other than these, what you can do is, write down all your project requirement and try to compare them with Pros and Cons of both Web Forms and MVC and if possible try to ask yourself following questions and point MVC and Web Forms accordingly
  1. Does your team have good experience with Web Forms or Windows Forms? Well, if yes then probably learning ASP.NET MVC is going to be a tedious task for team, because developers have been used to with ViewState and event driven programming by now and migration is going to be a difficult task.1 point to Web Forms.
  2. Does your team have good experience with ASP.NET MVC? If yes ASP.NET MVC get 1 point
  3. Does your team have experience on ASP or non-Microsoft technologies such as android, ios, JSP, ROR, PHP? If you have been JSP or ASP developer prior then you might be familiar with HTTP get and Post and even u might have hands on with MVC because most of them use MVC by default. It gives 1 point to ASP.NET MVC.
  4. Is JavaScript going to be used extensively? If Yes, MVC gets the point because you get complete control over HTML. 1 point ASP.NET MVC.
  5. Looking for good performance? With no support for ViewState ASP.NET MVC provides good performance gain over traditional ASP.NET Web Forms.1 point ASP.NET MVC.
  6. Planning to reuse the same input logic? If yes stick with MVC.
Source: http://www.codeproject.com/Articles/528117/WebForms-vs-MVC

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...