Iterating over a nested Member

You have a Collection of Products. Every product effectively maps to an Item. Now I needed to bind this Product collection to a grid and display the item name. So basically it would be something like prod[i].Item.Name or any other property can be accessed for item. Basically the idea is to Iterate over an inner member inside every element of the parent collection.

If you wanted to bind this with a GridView you can have very complex Databinding syntax for this by casting the items etc. Another option that I wanted to bring up here is creating an IEnumerable view using the parent collection.

public class ProdItemList:IEnumerable


    private List<Product> Products;


    public ProdItemList(List<Product> products)

    { this. Products = products; }


    public IEnumerator GetEnumerator()


        foreach (Product product in Products)

            yield return product.Item;



You can then bind the DataSource and it would effectively bind to the properties in Item. With something like ItemGrid.DataSource = new ProdItemList(products);

 I really liked this article regarding IEnuerable and 2.0. I am sure there are many approaches for this but just thought i’d put it down here for further discussion.

Hiding UpdatePanel during UpdateProgress

This was a very simple requirement to hide the currently updating controls. I first ran to the the forums and came across this. The trick was quite simple. When we depend control inside the updatePanel this technique fails. The idea is to wrap the update panel inside say another container like a div and set the control ID to that. The below script triggers the hiding of the control and kicks off the UpdateProgress.

    <script type=”text/xml-script”>

        <page xmlns:script=“″>


                <control id=GridContent visibilityMode=“Collapse”>


                        <binding dataContext=“_PageRequestManager” dataPath=“inPostBack” property=“visible” transform=“Invert” />






[Atlas] rules :)

For those of you guys who arent convinced yet, I have attached a hello world version to this.

DatacontractSerializer and ASMX service using types with Namespaces

When we try to generate a proxy out of an ASMX service with svcutil, there might be some interesting scenarios. One that I came across is when the service exposes types that have a root namespace. Now if you had only that type as the parameter then these doesnt seem to be any issue. As soon as you mix a primitive type with them then you get this error.


E:SajayVisual Studio 2005WebSitesAsmxDC>svcutil  http://localhost:2665/AsmxD


Microsoft (R) Service Model Metadata Tool

[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4312.0]

Copyright (c) Microsoft Corporation.  All rights reserved.


Attempting to download metadata from ‘http://localhost:2665/AsmxDC/Service.asmx?

WSDL’ using WS-Metadata Exchange or DISCO.

Error: An error occurred in the tool.


Error: Wrapper type for message HelloWorldRequest cannot be projected as a data

contract type since it has multiple namespaces. Consider using the XmlSerializer

Now if we really wanted to use the Datacontract serializer then its quite simple. Provided we didnt get this exception before we added primitive type parameter and the type itself can use the DatacontractSerializer then we can add the XML namespace attribute to the parameter.

using System;

using System.Web;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Xml.Serialization;



public class Item


    public string Name;

    public string Description;



[WebService(Namespace = “http://myWebsite/”)]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class Service : System.Web.Services.WebService



    public string HelloWorld([XmlElement(Namespace = “http://mywebSite/Types”)]string name,

        Item item)


        return name+” says Hello World”;





What do you stand for?

I dont know why i am a sore looser. If necessary I know I am the kind of person who can take care of you for a long time.
I don’t realize how people react and I have always failed to see the sense and reason as to how people take out anger.

I know I am a weird one. I keep myself aloof from everyone when I am angry with someone. This is not how people express it. They have different ways of doing it. I have seen people wallow in self pity when they are angry. I have seen people turn their faces from people who they are angry with. I know people who bitch about people when they are angry. I have seen people who shout at people when they are angry.

I accept all forms of representation are different signs of letting the heat out. But when you are the target for someone’s anger how much will you take it. I really respect people who are brave enough to face it cause they are the reason for it. I on the other hand have been the coward who cant stand upto it. I realize that I have made a mistake but yet am not ready to take it for some reason I yet have to come to terms with. Because of this I fail to make up properly after a fight and this is always been my drawback in life.

I have had issues before where I have not stepped down. I apologize. I my eyes the apology is given only when you mean it and it is in all respects a sign that I have acknowledged my mistake. But when people demand your apology in a way they require it, it has thrown me off and I have tried sometime but usually failed. I dont know if they realize I have tried.

Anyway my whole point is I break when people break me. They dont realize it but it bruises m bad and especially when the person is close.
I think this is an advice I am giving myself, if the person wants to let if off understand that everyone is not like you.
But then again i think that shouldnt the other person also know that you might not be able to take it.

After all this i realize that I am always wrong.

Hope i dont pay too much for not standing up to things in life.


WCF Service with .asmx extensions

We already have quite a large number of ASMX services and clients. One major point to be kept in mind is that WCF and asmx services can co-exist without any problem and migration to WCF should be your first and only choice unless there is a reason like using security that you do not have already. Or other WS protocols that you need for expanding your serivce.

When migrating there are a number of scenarios one can encounter. One of them is moving an asmx service to WCF withouth changing the undelying client. This would also include not changing the endpoint address to which the client talks to. Now if the client points to something like how can you make this a WCF service? There are 2 main scenarios when doing this.

 Without AspNetCompatibility mode.

This is a rather strainght forward approach and can be achieved through the following steps.

1.      Add a service host file called service.asmx with the following

<%@ServiceHost language=c# Debug=”true” Service=”WCFAspCompat.service1″ %>

2.      Add the following to your web.config file




        <remove extension=.asmx/>

        <add extension=.asmx type=System.ServiceModel.Activation.ServiceBuildProvider, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 />






With AspNetCompatibility

This requires one more configuration for the httpHandlers and can be achieved with the following steps.

1.      Add a service host file called service.asmx with the following

<%@ServiceHost language=c# Debug=”true” Service=”WCFAspCompat.service1″ %>

2.       You have to remove the .asmx handler initially. Add the following to you Web.config to get this working.




      <remove path=*.asmx verb=*></remove>

      <add path=*.asmx verb=* type=System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

          validate=false />






        <remove extension=.asmx/>

        <add extension=.asmx type=System.ServiceModel.Activation.ServiceBuildProvider, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 />





3.       Get your service setup as a aspNet Compatibile service
refer this post.






Moving along a broken road

Most of us look forward to a happy life. What is happiness? Have we compromised on everything to be happy? I have felt that for a long time and well the fact that I have had to makes me realize that there is nothing called a compromise. If you are happy then you lucky cause you have not succumbed to other side.

Lets take a small child. He see’s an animal and is amazed with it. Not because he knows its an endangered species. But because he sees the beauty that nature is capable of. I am currently in seattle and there are so many small things I see and enjoy here. But i cannot smile cause there are bigger things in life that I miss. I dont know if my compromises in life will leave me disturbed forever. There are so many things that excite people. I am not anymore. I look at the sun imagining the day when I would not see it again. I look at a beatiful woman and wonder what is it that makes her beautiful. I have lost the person in me who appreciates things as they are. Everything needs a reason and I have been scarred. I am frightened to ever again jump into the ocean of emotion cause I have realized I cannot cope with it.
People call me “Black and White”. They have realized i dont see emotion, I see facts. I ask why when they expect me to console them as to the fact that they are hurt. I dont know if I would become a person who can see from another person’s eyes cause I see it as vision and light and not a picture. I see a blend of colors when people see beauty. I see numbers when people see victory in a score. I see black when people see fear in a dark. I see just a beating heart when people see light. I am black and White. I am fact and I am just a human being. And I know I am alive only till my heart beats and it right now doesnt beat for me.

Using a Session in WCF through AspNetCompatibility

Firstly let us all thank [SteveMaine] . The session/state model is the same that is leveraged by the framework and hence all the feature of state management comes bundled with it.On a moral note its the responsibility of using this is upto the designers. But there might be applications and scenarios that may exist or require this to be supported.The basic steps are quite simple for this.1. Enable compatibilty on the serivce hosting environment.

<system.serviceModel>      <serviceHostingEnvironment aspNetCompatibilityEnabled="true">....

2. The service type should next specify the compatibility requirements. Please keep in mind that this is specified on the ServiceType and not on the Contract as it is the service type that handles the implementation.

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]public class service1 : IService1{....}

3. The final piece in this is that the client should enable this stateful communicaiton with the service. This is done by specifying the allowCookies to true in the binding. If you do not enable this then you wont find the session behaving as you want it. You will find that the session for each request is different even if the call is against the same proxy. Another important point to note here is that the session is tied to the instance of the proxy. So with each instance you need to remember thats it comes with a new session. This is the configuration that you have to tie with the endpoint consuming the service.

<basicHttpBinding>     <binding name="BasicHttpBinding_IService1"         allowCookies="true" /></basicHttpBinding>