200 Useful .NET Tips and Tricks

Daily .NET Tips is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET.  Today we have completed 200 Tips and Tricks with different areas. We Mainly focused on the practical oriented problem.

Major Tips categories :

Apart from that we have many tips on Silverlight, WP7 , C#, IIS , IIS Express etc..

How to retrieve HTTPModule details from HttpModuleCollection ?

In one of my previous post I have talked about How to get list of all active HttpModules in ASP.NET? Where I have explained how we can get list of all active modules of an ASP.NET Application at runtime. In this post, I am going discussed about, how you can get details of a particular module details from list of modules.

15 Tips from Daily .NET Tips

Daily .NET Tips is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone use in daily development work and targeted anything related with .NET. Here I am sharing few frequently required tips which are already published over there.

  1. How to count number of active session for State Server Session Mode ?
  2. How to use Runtime Objects in Watch Window during debugging in Visual Studio ?
  3. How to calculate Session data size for SQL Server session mode?
  4. Know when your application pools recycling in IIS 7.5 – Log an entry in Event Viewer while recycling
  5. Workaround For Non Serializable Types
  6. How EnableViewStateMAC Makes ViewState Secure ?
  7. Different approaches to Casting
  8. How to Display “Yes” or “No” Instead of Checkbox while binding Boolean value with GridView ?
  9. Changing Variables Display Format in Watch Window
  10. Getting Added And Deleted Items In A List Using LINQ
  11. How to setup multiple startup projects in Visual Studio ?
  12. Displaying Custom Messages / Images with NULL Value in ASP.NET GridView
  13. ASP.NET Validation Control with Images Notification
  14. How to expand specific Tree View Node programmatically in ASP.NET ?
  15. Display custom messages or images when there is no records in GridView Data Source

For more tips please visit  http://dailydotnettips.com and follow @DailyDotNetTips at Twitter

Thanks !

Details explanation on Compression Enabled Session for SQL Server and State Sever Session Mode in ASP.NET 4.0

While we are talking about state management we consider Session is one of  most useful server side  state management mechanism for a web application.  In ASP.NET mainly we are having two type of state management  1. In Process  and 2. Out Process . In process is the by default session imagestorage mode for ASP.NET Web application and this is taken care by worker process in IIS. When it comes under Out Process we can use either of state server or SQL Server to persist session data. In case of In Process, session data stored in In memory of worker process. But when we are talking about OutProc session mode, we need to ensure that session data should be Serializedfirst . So, when we are moving session data from Web Server to Out Process Server ( State Server or SQL Server ) it can be a performance overhead based on the size of data that we are storing in Session.

ASP.NET 4.0 comes with a new option for compressing the Session data with Out Process Session mode. To enabling this functionality we need to add “compressionEnabled=”true” attribute with the SessionMode in web.config .

Programmatically Changing Session State Behavior in ASP.NET 4.0

Session is one of most important state management in ASP.NET. We can enable or disabled session state either in web.config or using @Page directive’s   EnableSessionState attributes. But there was no provision to change the session state at runtime till date in ASP.NET. But using  ASP.NET 4.0, we can change the session  state programmatically . The .NET 4.0 framework adds a new method SetSessionStateBehavior  to the HttpContext class for ASP.NET. This method required SessionStatebehavior  value to set the current session mode. To call SetSessionStateBehavior   simply create a new HttpModule by Implementing IHttModule and hook the BeginRequest event. Most important you can only use the SetSessionStateBehavior  until the AcquireRequestState event is fired, because AcquireRequestState  Occurs when ASP.NET acquires the current state  that is associated with the current request

While calling SetSessionStatebehavior, You can pass the following values as SessionStatebehaimagevior  :

  • Default: This is default setting which means  everything works as before
  • Disabled: Turned of Session Sate for Current Request.
  • ReadOnly: Read only access to Session State;
  • Required: Enabled session state for both Read and Write Access;

Code Project Most Valuable Professional (MVP ) – 2011

MVP I have received an MVP Award for 2011 from Codeproject.com . This is my third time in a Row I am receiving the prestigious award from CodeProject. I have been awarded MVP from Codeproject  for my article  contribution and the responding to the technical answer in ASP.NET and C# Forums .

I would like to congratulate to all the Code Project  MVP -  2011

You can find the list of all MVP’s from Code Project MVP 2011

Thanks to all of you for  support and great feedbacks on my posts.

My Blog 2010 in review by WordPress.Com

Just received an review email from WordPress .com Team on my blog over year 2010. Sharing with all of you !

Your 2010 year in blogging

Happy New Year from WordPress.com! To kick off the year, we’d like to share with you data on how your blog has been doing. Here’s a high level summary of your overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Wow.

We think you did great!

I wish you a Happy New Year 2011

Wish you and your family a  very happy and prosperous New Year in year 2011. May this new year bring many opportunities your way to explore every joy of life. I Hope this New Year fills your life with happiness and perfect health always, much more success and happiness.

As we wind up with year 2010, I would like to express my sincere thanks to all the visitors, readers, followers of my blog for their encouragement, feedbacks and support.  Please keep visiting and send me your feedback. Based on your feedback, I have launched another site Dailydotnettips.com explicitly for .NET Tips.

In a personal note, one of my best moment in year 2010 was getting married with Ananya.

There are many new things coming at “Abhijit’s World of .NET” for all of you in year 2011. So, Keep visiting here and follow me @AbhijitJana for quick update.

Again, Thanks you and a very very happy new year 2010 !

Thanks !

AJ

.NET Tip a Day, Keeps painkillers away! – Live at http://dailydotnettips.com – 27th Dec 2010

logo1 Finally I have finished with designing, developing and deployment of  my new web site for “Daily .NET Tips” and this is now live at http://dailydotnettips.com . A single tip can improve productivity of work while coding. Daily .NET Tips is aiming to sharing useful coding tips and tricks for .NET Developers. This site completely design for sharing Tips and Tricks, useful Code Snippet which anyone can use in their daily development work. I had this plan for a long time for launching this site after seeing great response on my different tips at my blog itself. Finally It’s done.

Wishing you all Merry Christmas

image Here’s wishing you all the joys of the season. Wish you and your family a Merry Christmas and a prosperous New Year in year in advance. May this good times  become the golden memories of tomorrow for all of you. Wish you lots of love, joy and happiness.

Thanks for all of your response and support on this blog. A quick announcement from my side, After getting  huge response from all of you on my .NET Tips,  I am moving my .NET Tips section to a completely redesign web  site http://dailydotnettips.com.NET Tip a Day, Keeps painkillers away!” , exclusively for .NET Tips and Tricks. This site is now under development. Will be launch on 27th December 2010. I will really appreciate if you can visit the quickly and let me know your feedback. I will do a separate blog post on the launch date of Daily .Net Tips, about how I will move with that site.

Again, Merry Christmas and Advance Happy New Year !

Best Regards,

Abhijit

My Session Summary – Microsoft Community Tech Days – 18 Dec 2010 – Hyderabad

Community Tech-Days (CTD)  is a Microsoft technology event organized by Microsoft and Local Slide1 Microsoft User Groups  to help developers and IT Prof. to catch up with the latest Microsoft  technologies. Hyderabad Community Tech Days was held on 18th December at Microsoft IDC Building , Microsoft Campus, Hyderabad.  Event was full of  large number of technology enthusiasts and a number of regular event speakers from various technologies present for the event. Audience was awesome. Overall 350+ attended this event for both the Developer and IT Track  and many more via live streaming. Live streaming was available only for developer track. I have presented a session on “ASP.NET 4.0 State Management Improvement -  Deep Dive” .

Microsoft Virtual Tech Days – 22nd To 24th November 2010

The 10th edition of Virtual TechDays – being held on 22-24 November, 2010. I am gladVTD to say that I will present a session on “Debugging Web Application using IntelliTrace” on 23rd November from 4.15 PM To 5.15PM IST. In this session I will explore one of the coolest and most important features of Visual Studio 2010,  IntelliTrace debugging and will show you demo on how we can use this features for an ASP.NET  web applications. This is an live meeting event. You can attend it from any where.  To register for this event click here . Find all the details agenda from here . Tune in for a demo filled session.

How to Use ASP.NET “Property Pages” to create or host a Silverlight application in ASP.NET Site ?

While creating a Silverlight application in Visual Studio 2010, after providing the application name, IDE asked for whether you want to host the Silverlight application in a new ASP.NET web site or not. If you select the “Ok” button , Visual Studio will create a ASP.NET Site to host the corresponding Silverlight Application. So whenever you will run the Silverlight application, ASP.NET site will automatically host the Silverlight file  But suppose you have an existing Silverlight Application and you want to host it in a ASP.NET site in a similar way that New Silverlight project does  or you want to add a new Silverlight application which will automatically host inside your current asp.net web site? Do you know we can easily achieve this using “Property Pages” of an ASP.NET Application. Let’s explore how we can do that.