razor: 1 2 3 4 5 <code><form action="" method="post"> <strong> <input type="submit" value="Save" name="action:Save" /> <input type="submit" value="Send" name="action:Send" /></strong> </form> </code> <code><form action=”” method=”post”> <strong> <input type=”submit” value=”Save” name=”action:Save” /> <input type=”submit” value=”Send” name=”action:Send” /></strong> </form> </code> and controller: 1 2 3 4 5 6 7 8 <code> [HttpPost] <strong>[MultipleButton(Name =…
Continue readingCSharp
Handle the unhandled exception in Window Service C#
Sometimes window service crash due to unhandled exception occur in the code. Which cause service to be on halt without any error log and we are unable to restart or stop the service in the windows. In .net framework 4.5, Microsoft provides a method to handle the exception in the async event handler. Simply write…
Continue readingContent negotiation in WebAPI or other rest service.

The Accept header is used by HTTP clients to tell the server what content types they’ll accept. The server will then send back a response, which will include a Content-Type header telling the client what the content type of the returned content actually is. However, as you may have noticed, HTTP requests can also contain Content-Type headers. Why? Well, think about POST or PUT requests….
Continue readingDifference between Covariance & Contravariance
It’s probably easiest to give examples – that’s certainly how I remember them. (covariant return types/contravariant parameter types) Covariance Canonical examples: IEnumerable<out T>, Func<out T> You can convert from IEnumerable<string> to IEnumerable<object>, or Func<string> to Func<object>. Values only come out from these objects. It works because if you’re only taking values out of the API, and it’s going to return something specific (like string), you can…
Continue readingSingle vs SingleOrDefault vs First vs FirstOrDefault
When to use Single, SingleOrDefault, First and FirstOrDefault You should take care of following points while choosing Single, SingleOrDefault, First and FirstOrDefault: When you want an exception to be thrown if the result set contains many records, use Single or SingleOrDefault. When you want a default value is returned if the result set contains no…
Continue readingStack vs. Heap
Here are our two golden rules: A Reference Type always goes on the Heap; easy enough, right? Value type always goes on the Stack. Value Types: In C#, all the “things” declared with the following list of type declarations are Value types (because they are from System.ValueType): bool byte char decimal double enum float…
Continue readingDifferences Between Hashtable and Dictionary
1. Hashtable is threadsafe and while Dictionary is not. 2. Dictionary is of Generic type whereas Hashtable is not of generic type. 2. Dictionary is types means that the values need not to boxing while Hashtable values need to be boxed or unboxed because it stored the values and keys as objects. 3. When…
Continue readingWhat is mutable and immutable. Difference between string vs sting builder
When u change the value of Mutable objects the new memory is created and new value is stored in new memory.But in immutable the value is changed in same memory, this makes immutable objects to increase the performance.so in case if the string is frequently changed in the code at run time, it is advisable…
Continue readingFactory pattern C#
Introduction The factory pattern method is a popularly used design pattern and it is very useful to restrict clients from knowing the actual business logic methods, it is useful to create a decoupled system, and it is useful to eliminate object creation in a client environment. This article explains how we can achieve these problems…
Continue readingSingleTon Pattern C#
A singleton is a class that can be instantiated once, and only once. To achieve this we need to keep the following things in our mind. 1. Create a public Class (name SingleTonSample). 1 2 public class SingleTonSample {} public class SingleTonSample {} 2. Define its constructor as private. 1 2 private SingleTonSample() {} private…
Continue reading