Skip to main content

Posts

Is your client request missing from IIS log?

One can enable IIS logging by going to IIS Manager and checking the Enable logging checkbox. So, it means if IIS logging is enabled, then each and every request made by the client should be showing up in the IIS log. Isn’t it? But by any chance, if the request is not present in IIS log then the most probable reason would be either IIS was not running or may be request was not made. But this statement is not 100% correct. Because whenever any request is made to the server, first it routes through HTTP.SYS then it comes to IIS. So, if anything is not visible under IIS logs, then one can see the logging for HTTP.SYS which is HTTPERR . The most common errors logged here are related to timeout or service unavailability. The next question would be, where these logs are exactly saved? You can find HTTPERR under C:\Windows\System32\LogFiles\HTTPERR

Unable to launch IIS Express from Visual Studio

Recently, while working on one of the web project, I came across a situation which ate up my almost an hour. Concern was, my IIS express was not launching automatically on running my web application from Visual Studio 2015. I tried various solutions like, ran the Visual studio as an Administrator, changed the port, disabled the firewall, reset the IISExpress folder. But no luck :( Then I thought, let's give a try by deleting the temporary folders which were created by Visual Studio and guess what? That worked for me.   The culprit was the .vs folder which was the hidden folder in the project's root directory. One of my colleague checked-in that folder by mistake and as I was fetching the code for the first time, it came on my machine. Actual felon was the .suo file which was inside .vs folder. This .suo file contains user specific settings. Hence same user settings didn’t work for me.   Solution - Deleting .vs folder did the trick :) Happy troubleshooting !!!

Possible Multiple Enumeration of IEnumerable

If you have worked with IEnumerable and using ReSharper , then you may land up into this warning, " Possible Multiple Enumeration of IEnumerable ". So, what this warning is all about? Well, before proceeding further, let’s see how we can store something into IEnumerable object . IEnumerable items = GetAllItems() So, above code itself speaks that items is a variable of type IEnumerable which will hold some values/objects we can iterate through. Now here lies the performance hit, which is also indicated in the form of ReSharper warning. This performance hit may not be significant for a small number of items. But this can be noticed while dealing with a huge number of items. Reason behind this is, whenever you are iterating through items collection, GetAllItems method will be called for the same number of times. Solution : It is always good to materialized the result in a list or array like below: IEnumerable items = GetAllItems().ToList() Once you are done w

.Net Architecture Guidance announced

Few days back, Microsoft announced the draft version of the .NET architecture guidance. This guidance is the combined effort of the Visual Studio team and the Microsoft Developer Division. As of today, it covers only 4 areas: ASP.NET Web applications Azure Cloud Deployment Xamarin Mobile Applications MicroServices and Docker You can find more about this guidance on Microsoft's documentation.

Why normal .NET exception handling doesn't work in WCF?

Errors and exceptions are part of our programming life and WCF is no different. So, when we get errors in WCF, we would like to propagate those errors to our WCF client so that they can accordingly take actions. In order to demonstrate this, let’s go through the code of a simple service: public int Add(int number1, int number2) { return number1 + number2; } public double Divide(int number1, int number2) { return number1 / number2; } Both the above methods will perform some calculation and return the result to the client. Let’s say, now for some reason someone sent 2 nd parameter of Divide method as 0.  What will happen? Definitely code will throw an error or say DivideByZero exception. Isn’t it? Know how to handle this error? Most of the developers will simply decorate Divide method with Try-catch block and throw the exception, similar to our normal .NET exception handling mechanism as shown in be

Which WCF template to be used?

Recently, one of my colleague asked me, which WCF template should I use to create a service? For experienced people, it may be a silly question, but it is one of the common question among beginners, who just entered into the world of services. That’s the motivation who made me write this small post. Well, let’s first have a look at what all templates are available in Visual Studio 2015 for WCF:  The developer can choose any of the above templates as per project need. Let’s go through them one-by-one. WCF Service Library: This template is nothing but a simple service library which uses App.config as its configuration file. WCF Service Application: This template will create a web site which in turn will be hosting a service in it. Here Web.Config will be used to serve configuration settings. WCF Workflow Service Application: This template is useful when you want your workflow to be accessed as a web service. Syndication service Library: This te

DependencyObject in ViewModelBase - Good or Bad?

First of all, a very-very Happy New Year to all my readers. If you are reading this post, then I’m assuming that you have a working experience of WPF using MVVM.  Don’t worry, I’m not going to re-write a huge post on what MVVM is and where to use it? This blog is very small which talks about one of the best practices any developer implementing MVVM should follow. Well, let me provide you the context first. Last week I was going through one of my colleagues’ code and noticed few interesting things in his ViewModelBase class: It was holding few Dependency properties  It was inheriting  DependencyObject  How it sounds to you? Good or … ?  Of course, that is not at all a good practice as ViewModelBase is the base class for all the ViewModels and is not supposed to contain such code. Well, this is not the only reason.  There are many other reasons which are making this implementation a BIG NO.  1 st Reason – A DependencyObject was never meant to be a Source of a bi