Skip to main content

Posts

Showing posts from September, 2014

Custom serialization Using Newtonsoft.Json

When using Newtonsoft. Json to serialize objects, we can avoid few properties from being included in the output for some use case and the same property be included in the serialized output in other cases. There's a feature in the Newtonsoft.Json.NET library, that lets us  determine at runtime whether or not to serialize a particular property of a class / object. During the process of creating a class, we have to include a public method named ShouldSerialize{MemberName} returning a boolean value. Json.NET will call that method during serialization to determine whether or not to serialize the corresponding property of the class. If this method returns true, the property will be serialized; otherwise, it will be ignored. The following illustration shows how this can be achieved. The following is a data definition / class that may be serialized using Newtonsoft.Json.Net public class AuthTypeClaimMapViewModel {     [JsonIgnore]     public bool? _canSerializeName { get;

Restoring a Database using bak files and SQL Scripts alone

The following is the script to restore any database from a .bak file without using Sql Server Management Studio -- The database name in the restored bak file should be the same as the one given here RESTORE DATABASE [authserver] FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL11.LOCAL\MSSQL\Backup\database.bak' WITH FILE = 1, MOVE N'authserver' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.LOCAL\MSSQL\DATA\database.MDF', MOVE N'authserver_LOG' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.LOCAL\MSSQL\DATA\database.LDF', NOUNLOAD, REPLACE, STATS = 10 GO

The world is as we see

An extrovertish view of the world around On the eve of a well started thursday, the penultimate day for a long work week, as often seen as this day 27th Feb 2014, I started my journey from my office working my way round to my home which stands farther from my office by approx 497kms. I made my way to the railway station, where we begin onboarding the train's to one's natives that are distant by approx 4hrs travel. My eldritch intuition began ringing within to pull off the strings from office to break for the week a day earlier and reach home to meet my lone parents. I reserved my berth in a train that get its ends loosened from the national capital a day before the ones that typically leave to my home town from my worktown, a sluggish way to get a confirmed birth. Though seemingly easy for an outsider, I have my painful way to kick-start off my travel by hurting myself for a two-and-a-half hour journey by scrambling for a seat to get me kinda comfortable for the next two-an

World Peace day

As a protraction to the world peace day, I wish to present an extemporary propaganda. How about you making a wish now, for an ally or foe or a protagnoist (call it whatever) without an outlook. When you call it a day, just spare a couple of moments to ruminate on how was the day, had you experienced something good, be it a wish from someone. Had this wish bubble be kept springy, the world will ever require a day dedicated for world peace.

Static file content not served by IIS

Recently on encountering a issue where in the images / CSS / js and others being rendered with status as 200 (OK). But when looked in the browser, the content was not displayed. The static modules were enabled in windows features along with the MIME type mapping. Finally, when checking in the IIS Server, it was found that the Static module was missing in the handler registration. Updating that fixed the issue.

Could not load library when hosting the app in IIS

When an application is deployed in the server and if it throws the could not load library exception, we can enable the x86 support in application pool. In case any assembly was built targeting the x86 platform, this would be the right fix to make the site available. However, it is strongly advised not to target specific platform unless a firm reason be found.