Jun 26, 2016

How to change Asp.net Identity token expiration in Asp.Net Core or MVC 6

Asp.Net Identity default expiration time is 1 day. Some time its require to change based on our requirement.

Default property initialization on DataProtectionTokenProviderOptions class is
 public TimeSpan TokenLifespan { get; set; } = TimeSpan.FromDays(1);

Require customization for change to default token expiration time.

Following step require to change default expiration token time.

Step 1 : Create new class with name DefaultDataProtectorTokenProviderOptions and Inherit from DataProtectionTokenProviderOptions class.
public class DefaultDataProtectorTokenProviderOptions : DataProtectionTokenProviderOptions { }

Step 2 : Create new class with name DefaultDataProtectorTokenProvider and Inherit from DataProtectorTokenProvider class.
public class DefaultDataProtectorTokenProvider : DataProtectorTokenProvider where TUser : class
    {
        public DefaultDataProtectorTokenProvider(IDataProtectionProvider dataProtectionProvider, IOptions options) : base(dataProtectionProvider, options)
        {
        }
    }
Step 3 : Time to use above classes on Startup class and AddTokenProvider.
Step 4: Declare private variable for provider name
 private const string _defaultTokenProviderName = "Default";

Step 5 : Under ConfigureServices method add following code for token expiration time change.


Here you can see set time span for token expiration.
// Set time span for token expiration time
           
                options.TokenLifespan = TimeSpan.FromMinutes(15);
           

You can get the source code from GitHub.

Hope you like this so please keep reading.

Jun 20, 2016

Web Essential extension for Visual Studio

Visual Studio supports extensions and There are so many useful extension available in market for Visual Studio. You can be lots more productive using this extension. “Web Essentials” is one of the best extension available for visual studio. It has been developed by Mads Kristensen. You can download this extensions from the following link.

http://vswebessentials.com/

There are different versions available for different versions of visual studio. There is lot of features available in web essentials for the HTML, CSS and JavaScript editors.

Web essentials features:
There are so many features available in visual studio 2015 web essentials. We are going to cover only few.

CSS Vendor specific properties:
There are lots of CSS vendor specific properties available specially for Mozilla family. So now you can add those very easily via web essentials.



Color preview in CSS:
Now we see that color previews are available with web essentials:



JSHint:
JS hint is really good for following JavaScript coding standards. There settings with from where you can define the coding standards for the same. 

Syntax Highlighting:
There are lots of more syntax highlighting provided i.e. Robot.txt, HTML5 App Cache and few more.

Markdown:
It’s provides great features like syntax highlighting, intellisense for embedded language features, preview features, custom stylesheet etc.



There are many more features available. You can visit following link know more about Web Essentials features.

http://vswebessentials.com/features/

That’s it. Hope you like it. Stay tuned for more!!