IIS 7 not loading CSS and Image

Yesterday, I faced a wired yet crazy issue. My machine has a bit freshly installed windows 7 and so while running web site hosted on local IIS, I was getting a pretty plain asp.net pages without CSS and Images being loaded properly.

After a little investigation, it appears to be a problem with Windows feature installation. All you have to do is run ‘optionalfeature’ command and make sure ‘Static Content’ option is checked.

Windows Features - Static Content

Hope this would help you, if you face similar kind of issue.

Client Additional Parameters using Custom Headers in WCF

When building Service communication applications using Windows Communication Foundation, we often come to a situation where we have multiple clients communicating with WCF Service and we need to pass additional parameters from client to service. This may be due to number of reasons such as sharing a unique customer ID to identify certain elements for that particular client. In such scenarios, for every communication between client and server, you need this unique ID to treat each client accordingly.


In a typical disconnected environment over the internet you need to pass such data on each call to service and of course passing in each Service Method or Operation Call is confusing and not appropriate.

A good Solution is to pass additional parameters in SOAP headers utilizing with the help of Custom headers in WCF. A SOAP envelope contains a header and a body. Method call and its parameters are transformed to SOAP body whereas SOAP header usually contains application-specific information (like authentication etc.)


A simple way to achieve this in WCF is to add MessageHeader in your proxy class as in code snippet below:

public partial class TestServiceClient : ClientBase<Client.ServiceProxy.ITestService>,
    public TestServiceClient()
        var header = new MessageHeader<string>("Customer Unique Id: 12345");
        var untyped = header.GetUntypedHeader("Identity", "http://www.adilmughal.com");
    //Other constructors and Service Method Calls

However this is really NOT a suitable approach as if you would be generating proxy using svcutil.exe or using Visual Studio then it will replace your proxy code.

A Better Solution to solve this problem is to utilize custom behavior extension in WCF to pass additional parameters in SOAP Message header. Following are the steps required on client:

1) Implement IClientMessageInspector to create custom message inspector

public class MyMessageInspector : IClientMessageInspector
    #region IClientMessageInspector Members
    public void AfterReceiveReply(ref Message reply,
                                    object correlationState)
        Console.WriteLine("SOAP Response: {0}", reply.ToString());
    public object BeforeSendRequest(ref Message request,
                                    IClientChannel channel)
        var header = new MessageHeader<string>("Customer Unique Id: 12345");
        var untyped = header.GetUntypedHeader("Identity", "http://www.adilmughal.com");
        Console.WriteLine("SOAP Request: {0}", request.ToString());
        return null;

2) Create a custom behavior class implementing IEndPointBehavior and BehaviorExtensionElement. Then add the custom message inspector in runtime in ApplyClientBehavior method as shown in code snippet below:

public class CustomBehavior : BehaviorExtensionElement, IEndpointBehavior
    #region IEndpointBehavior Members
    public void AddBindingParameters(ServiceEndpoint endpoint,
                                        BindingParameterCollection bindingParameters)
    public void ApplyClientBehavior(ServiceEndpoint endpoint,
                                    ClientRuntime clientRuntime)
        clientRuntime.MessageInspectors.Add(new MyMessageInspector());
    public void ApplyDispatchBehavior(ServiceEndpoint endpoint, 
                                        EndpointDispatcher endpointDispatcher)
    public void Validate(
        ServiceEndpoint endpoint)
    public override Type BehaviorType
            return typeof(CustomBehavior);
    protected override object CreateBehavior()
        return new CustomBehavior();

3) Finally, register behavior in .config under <system.servicemodel>

      <customInspector />
    <add name="customInspector" type="Client.CustomBehavior, Client, Version=, Culture=neutral, PublicKeyToken=null"/>

That is all you have to do on client end to pass additional parameter in SOAP header using Custom Behavior in WCF.

To retrieve parameter passed in header on server side, you need to use OperationContext object

MessageHeaders headers = OperationContext.Current.IncomingMessageHeaders; 
string customParameter = headers.GetHeader<string>("Identity", "http://www.adilmughal.com");
return string.Format("You entered: {0}", customParameter);

This would achieve the objective. Following is the detail of SOAP Envelope:

SOAP Request:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ITestService/GetData</Action>
    <Identity xmlns="http://www.adilmughal.com">Customer Unique Id: 12345</Identity>
    <GetData xmlns="http://tempuri.org/">
SOAP Response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
    <GetDataResponse xmlns="http://tempuri.org/">
      <GetDataResult>You entered: Customer Unique Id: 12345</GetDataResult>

In this post we saw how to create custom SOAP header in WCF to pass parameter from client to server using WCF behavior extension. Hope this helps.

Visual Studio 11 IDE Improvements

This is second post of the Dev11 series. If you have not installed preview bits, you may like to read my previous post on “Visual Studio 11 Developer Preview”. In this post, I am going to share some of the improvements in Visual Studio 11 IDE.

//Disclaimer #1: This post is written for Developer Preview version, and features may change in later releases.
//Disclaimer #2: The views expressed in this post are mine alone neither of my employer nor of Microsoft.
//Disclaimer #3: This is a long post

The Visual Studio 11 IDE contains bunch of improvements/enhancements and some of them are modified/enhanced version of Productivity Power Tools extension available for Visual Studio 2010 which you might be familiar with. The reason I am really excited about this release is because, for the last two years, I have been involved in providing feedback to Visual Studio team as part of technical community and so one of the thing we discussed during MVP Summit was that Visual studio has lots of options, commands, windows etc. that are not known to developers and therefore it is important for developers productivity and experience to consolidate features and make them discoverable. I really think the VS team have done well in considering community feedback. So let’s discuss some of the improvements:

Solution Explorer

If you compare Solution Explorer of Visual Studio 2010 with Visual Studio 11, it has really improved a lot.

Solution Explorer in VS 2010 and VS 11

Solution Explorer - Browsing CodeNow you can utilize solution explorer for browsing types, type members, search symbols and find relationships among them. Thank God they have provided collapse button in Solution explorer… at times it was quite irritating to collapse projects etc.

You can now Browse Code within solution explorer, by expanding down types and type members. This helps in quickly jumping to a particular type member such as property or method. It further gives option to view call hierarchy (Calls, Is Called By, Is Used By) of a method via context menu.

  • Calls – display list of methods called by the selected method
  • Is Called By – display list of methods that calls selected method
  • Is Used by – display list of methods using selected method in line, similar to Find All References option

A great thing I have observed is when I have a large solution and I try to browse to type members level, the visual studio lazy loads the type members and populate the items which I believe must be adding value in terms of performance.

Solution Explorer - (Method) [Calls]Solution Explorer - (Method) [Is Called By]Solution Explorer - (Method) [Is Used By]

Searching symbols in solution explorer made it easy to find any class, methods, properties, in fact any symbol in code. For example, following image depicts the search result of ‘Mock’. You can also use (Ctrl+;) as shortcut to search using solution explorer. This is small but very beneficial feature for developers to quickly search for what they are looking for in code.


Finally the search results in Solution explorer can be viewed with single click on any item of the result list instead of double clicking class etc. which really allow developers to quickly jump between search results.

Quick Launch

Quick launch is one of the great features of this version. How many of you actually feel that it’s difficult to find options, commands etc. in Visual Studio? How many of you felt like forgetting a menu option? How many of you felt like it takes time to navigate through menus like Tools –> Options –> Debugging etc.? How many of you felt its annoying to remember shortcuts?

The Visual Studio 11 has answer for you in the form of “Quick Launch”. Quick Launch option is available on top right corner of Visual Studio or using shortcut key (Ctrl+`).


For example, I want to look for the option of formatting code or document or any other option related to format. Quick Launch allows me to simply search for ‘Format’ and it will show me all the commands and options related to that as shown below:

Quick Launch - Result

So this really gives me a quick way to search all the options related to Formatting instead of going through menus, especially if you don’t remember the shortcut.

Simplified Toolbars

You probably have notice that toolbar is single row with fewer, yet frequently used, options.

Visual Studio 11 - Toolbar 

This is because it has been observed that most of the developers tend to utilize only some of the commands in toolbar. For example, developers don’t use commands like Cut, Copy, Paste, Save and some other options from toolbar… they usually do it using shortcuts or don’t use them. So based on feedback and research, it has been simplified to most frequently used commands only. With toolbar consuming less space, now you have more SPACE for editor!

Concluding Remarks

That is all for this post, hope you enjoyed reading about the IDE improvements in Dev11. The Visual Studio 11 IDE contains bunch of other enhancements as well which I would love you share, hopefully in coming post.

Until next time, Happy Coding!

Visual Studio 11 Dev Preview

Like me, if you work on .NET platform and Visual Studio, you must be excited about the recent announcements of “Visual Studio 11 Developer Preview” or “Dev 11” at BUILD conference on September, 14, 2011. The next version of Visual Studio and .NET framework contains many new features and enhancements, making job of .NET developer easy.

Over the next few weeks, I am going to write series of posts on some of the new features and enhancements in Visual Studio IDE, C# and .NET Framework 4.5.

Getting Started:

To begin with, you can download Visual Studio 11 Developer Preview:

  • For MSDN Subscribers – link
  • For Everyone else – link
  • For ASP.NET Developers, download ASP.NET MVC 4 Preview for VS 2010 or VS 11 – link

If you have missed BUILD conference online, following are some of the overview talks related to Dev Tools:

Keynote # 2

Whats New in Visual Studio 11

Future Directions for C# and Visual BasicWhat's new in .NET Framework 4.5


I have installed Visual Studio 11 Developer Preview on my home machine side by side with Visual Studio 2010 on Windows 7. It seems to be working fine and installation was successful. I am not sure about proper uninstallation when I will go for beta later 😉

I downloaded the .ISO file as MSDN subscriber. Following are the snapshots for Setup.

Step 1Step 2Step 3

Step 4Step 5Step 6

For ASP.NET MVC 4 Preview, as mentioned, you need to download it separately either via Web Platform Installer for Visual Studio 2010 or Visual Studio 11 Dev Preview or directly from installer. I did it using Web Platform Installer for Visual Studio 11. Following are the snapshots for setting up ASP.NET MVC 4 Preview:

ASP.NET MVC 4 Installer (Visual Studio 11)ASP.NET MVC 4 Installer (Visual Studio 11) - prerequisites

ASP.NET MVC 4 Installer (Visual Studio 11) - InstallASP.NET MVC 4 Installer (Visual Studio 11) - Finish

Concluding Thoughts 

I am all done with setting up Visual Studio 11 Developer Preview and ASP.NET MVC 4 Preview. I am excited to see the implementation of some of the important community feedbacks we have provided to Visual Studio team over the time. So go ahead and download the bits if you have not done it yet. Coming up next is IDE Enhancements in Visual Studio 11, stay tuned!

As A Good Technical Lead

/* DISCLAIMER: This blog post is purely based on my personal observation and experience. The views expressed are mine alone */

Whether you call it Technical Lead or Dev Lead or Team Lead or Lead Programmer, this blog post is about the role and some of the characteristics Good Technical Lead must have.

A Central Role

Trust me, Dear Reader, if you are a technical lead or in a similar role you really have a central and significant position in the overall software development life cycle. Being the owner of the technical solution, your job is to ensure the smooth execution of development activities at least till the project is handed over for production.

Technical lead Role

You are not only face to the management but also a bridge between different groups such as software developers, architects, Testers, End users etc. You are also responsible for compliance of standards such as coding and design standards.

However, a reality is that this job role is more towards management and less towards technical.

As a Good Technical Lead…

To discuss the must have attributes of a good technical lead, let’s divide the title “Technical Lead” into two areas:

  • Technology
  • Leadership


Know the every bit of the solution you are working on. Dive deep and understand the big picture of the technical solution and the customers’ need. This will help you provide to contribute not only in the features/functionality proposed but also you will be able to guide developers in a better way.

Okay you neither have time in hand nor cost, the only thing you have in your hand is project/feature scope! Rule it!!!

Act as true mentor. Yes you did well when you was developer, now it’s time to share your knowledge with juniors, try to replicate your knowledge, your experience. Help them in managing themselves and their day to day development tasks.

Embrace new technologies and believe in continuous improvement. As a technical lead, you are required to always look for continuous improvement in software construction. Adapt new tools to improve approach and productivity over time. This will help develop learning agility in the team.

Ensure better design. Try to make good design and coding habit of your team.

Delegate the overall development tasks effectively. However, at times, it is suggested to do some percentage of coding as well. This will add more respect in front of your team. 

Your passion towards technology counts! after all it’s software engineers you are leading.


You will be interacting with different set of people with different attitude, different temper and different background. As an good leader you should have strong ability to listen people and listen them very well. Be clam and humble to hear their concerns and resolve them in best possible way.

As a lead developer, your every act should be inspiring for your team members. Also, It is important to walk your talk. We would definitely not like managers who does not act upon his own principles.

Know your team, their interests, their concerns, their strengths, their weaknesses and their growth.

Encourage team work and discourage blame game at least within the team. This will help people focus on the ultimate goal and will forgive each others mistake. Let them realize that they all win together and they all lose together.

Your ability to look in the cloudy future will reflect your proactive approach. Looking ahead of time and think what can go wrong will help you prepare for better execution tomorrow.

Maintain a positive environment and ethics within your team.


These are some of the attributes I think as a good technical lead one should posses. Please feel free to comment your experience or what you believe a good lead should have?

Sessions on Web Development

Good Job NED Volunteers Thumbs up 

Source: http://www.devnextug.org/2011/04/sessions-on-web-development-using.html

On request of students from NED University of Engineering and Technology, DevNext User Group recently organized two day sessions on Web Development using ASP.NET at NED University. The sessions were held on 12th and 19th March, 2011.

The purpose of facilitating such sessions was to provide students firm understanding of web architecture and development using HTML, JavaScript, CSS and ASP.NET.

We would like to thank speaker and our volunteers at NED University for organizing such useful sessions.

About Speaker:

Mr. Anas Raza is a graduate in Computer and Information System from NED University and currently working as Software Engineer at ITIM Pakistan.

About DevNext User Group:

DevNext is a user group which has been created with the intention of providing a platform for the Next Generation Designers & Developers sharing and discussing knowledge regarding different tools and technologies. Our mission from inception has been to develop a peer group of developers, designers, architects, and managers who are interested in learning, sharing and growing their knowledge and capabilities. The group’s vision is to provide members with a forum to hear top industry experts speak, learn and teach others who are interested in the same technologies as you and are facing the same challenges.

Interested in organizing technology sessions in your University? Please contact us at contact@devnextug.org and we will be happy to assist you.

2 Day Workshop on WPF for Faculty

Higher Education Commissions (HEC) and Microsoft Innovation Center (MIC) recently organized a 2 day workshop on Windows Presentation Foundation (WPF) for faculty and I was invited as trainer.

AdilWPF Workshop

The overall agenda of the 2 day workshop was to introduce Microsoft’s platform for building Windows client applications. The audience comprises of faculty from University of Karachi, NED UET, IBA, LUMHS etc. However, I consider it as an honor and opportunity for me to interact with the academia and share with them some of the current trends in technology and near future.

The best part was that we utilized our lunch and tea breaks as discussion forums where we discussed about Computer Science curriculum and how we can enable our students more to become better computer scientist, engineers and entrepreneurs. We also had discussion on where WPF fits in for computer science students.

It was really nice to interact with distinguished faculty members and I really enjoyed conducting the workshop.

Slides presented during the workshop are embedded below but I used whiteboard a lot during the workshop along with code demonstration using Visual Studio 2010 and so slides were merely for reference.

MVP Summit 2011–Trip Summary

I have recently returned back from USA after attending Microsoft MVP Summit 2011. The MVP Summit, an event hosted by Microsoft, provides a great platform for Microsoft Most Valuable Professionals (MVPs) to connect with each other and with Microsoft Product Groups. It is always exciting and interesting to attend summit and getting updates on Microsoft Product roadmaps and future improvements. The overall summit lasted for 3 days which I have summarized below.

Day 1 – Developer Day

The day started with Developer Day kick off session by Scott Guthrie and Jason Zander, where they demonstrated the overall direction and future work of Microsoft development tools and platform including ASP.NET, Visual Studio, Team Foundation Server, Silverlight, C#, Compiler as a Service etc.

Exciting thing was that I got opportunity to meet technology gurus such as Jeffrey Richter, author of famous book CLR via C#, Scott Gu, I guess every .NET developer know him.

Developer Day - Kickoff SessionJeffrey Richter - Author of CLR via C#With ScottGuC# Program Managers

Day 2 – Keynotes

Day 2 starts with the keynote from Steve Ballmer, CEO of Microsoft, discussing the focus of Microsoft company. This keynote was following by keynotes from Toby Richards and Ron Markezich. Listening to Steve Ballmer was really fun but rest of the keynotes were kind of boring to me.

Steve Ballmer - Keynote "Our Focus"Ron Markezich - Keynote "Future of Productivity"

Day 3 – Product Group Interaction

Day 3 was full of excitement and I really enjoyed that day because we had close focus group meetings with Product Teams which in my case were Visual Studio and C# team. Mostly, We had discussed on the possible improvements in the Visual Studio vNext, which we cant talk about it at the moment due to confidentiality. We also had opportunity to interact with C# Chief Architect “Anders Hejlsberg”.

Microsoft Campus ViewC# Architect - Anders

Overall It’s always good to attend the MVP summit which provides opportunity to build relationship with Microsoft Product teams, network with MVPs and provide feedback on Microsoft Products. I would like to thank Microsoft for awarding me “MVP Award” and providing such a nice opportunity to visit Microsoft Campus in Redmond, USA.

*Special thanks to people sending me email/tweet for feedback on Microsoft Products*

Attending MVP Summit 2011

*Excited* – I will be attending “2011 MVP Global Summit” from 28th February till 2nd March at Microsoft Headquarters in Redmond, USA.

MVP Banner

“The MVP Global Summit is a multi-day event that is hosted in Bellevue and at Microsoft headquarters in Redmond, Washington. With a large catalog of deep dive sessions and a variety of networking opportunities, the MVP Global Summit enables MVPs to connect with other MVPs, build relationships with Microsoft product managers, and provide feedback on Microsoft products and technologies.”

*Long Flight* – Yes that is pity, the flight duration from Karachi to Seattle is around 20-24 hours 😐 but hopefully connecting flights will give me some lag time to relax at different Airports.

*Getting Connected* – Perhaps one of the greatest opportunity that MVP Summits provide is to get connected with Microsoft MVPs and build relationship with Microsoft people.

I am really looking forward to attend the summit and hope it’s going to be fun. You can follow the event on twitter with #mvp11

Feedback to Microsoft

We will be having opportunity of direct interaction with Microsoft CEO “Steve Ballmer”, C# Chief Architect “Anders Hejlsberg”, General Manager – Community and Online Support “Toby Richards”, Senior Corporate VP Online Services “Ron Markezich”, and Visual Studio and Programming Languages Teams.

As I will be representing technical community from Pakistan, so if you or any of your friend have question or feedback for them especially related to .NET Platform, please feel free to send me directly via commenting below this post or email me at adil.mughal@live.com_no_spam. I will be glad to share with them on your behalf.