How to enable sessions in Web API

Web API does not support native HTTP sessions. And it’s the nature of Web API, but there might be times you need HTTP sessions which resembles your bad design. Because a service framework should not support HTTP sessions as it should be a stateless element. So why do we need sessions in Web API ?... Continue Reading →

Advertisements

AES Cryptography

Contains the code for AES encryption and decryption in C#. 1: public byte [] EncryptText(string plainData) 2: { 3: RijndaelManaged rij = new RijndaelManaged(); 4: 5: rij.GenerateKey(); 6: _key = rij.Key; 7:  8: rij.GenerateIV(); 9: _intializationVector = rij.IV; 10:  11: ICryptoTransform encryptor = rij.CreateEncryptor(_key, _intializationVector); 12:  13: using (MemoryStream msEncrypt = new MemoryStream()) 14: {... Continue Reading →

Adapter Pattern

Adapter pattern is often mentioned as wrapper in normal convention. It is a pattern which introduces loose coupling when creating a middle interface between two unmatched types. The name itself, self describes itself.  Think we have a class which renders a dataset on the screen. So we’ve a working class like this. class Renderer {... Continue Reading →

Singleton Pattern

Singleton pattern is a simple design pattern in software practice and sometimes considered as an anti-pattern due its tight coupling nature. A very simple non thread safe implementation of the Singleton pattern would be like this. Singleton non thread safe class Singleton {   privatestatic Singleton _instance;   private Singleton()   {     Console.WriteLine("Singleton instantiated");... Continue Reading →

Powered by WordPress.com.

Up ↑

%d bloggers like this: