Huthaifa Afanah

Huthaifa Afanah is living in Jerusalem and enjoying his time developing applications

  • Microsoft TechDays in Palestine

    For the first time in Palestine , Microsoft in cooperation with PalDev community will present 3 TechDays in Hebron, Ramallah and Nablus from 1st November till 3rd November. The main activity in the event will be the Official Launch of Windows 7 and Imagine Cup 2010. Other topics in the event will be as the following :


  • In Hebron “Introduction to VS2008 & ASP.NET” session

    As part of PalDev activities I was in Hebron this Saturday to deliver a “Introduction to VS2008 & ASP.NET” session for the PPU –Palestine Polytechnic University – CS and IT students. The workshop was held in Friends of Fawzi Kawash IT Center of Excellence (FFKITCE). We stopped the event registration process after 65 person was registered regarding the room limitation and we also emailed the latest 25 person that the priority will be given for those who registered earlier and we will re-hold a similar event for those who could not attend.

    Anyway I went to Hebron using public transportation and it was like using “Crazy Taxi”!! it was really a mad drive I reached with no harm and headed to the FFKITCE center. The presentation started after 12:00 pm and continued to 4:00 pm nearly. It was really a very quick 3 hours full with Microsoft Buzz.

    The audience was excited –I think- and I was very pleased to see those motivated students which really encouraged me myself to pursue latest tech’s further and further. The audience was interested with the powerful features the .NET and VS2008 provides which ease the application development process and save time and efforts. On the side of the presentation I introduced the express editions Microsoft offers, Microsoft Dream Spark and MSP programs.

    In general the presentation run smoothly except that I could not figure out what happened in the second demo when my VS 2008 refused to connect to adventure works sample database. Although I checked the sample scenario early that morning and it was running fine but this is the demo’s hell I really tested –many times probably- !! Anyway we was already exceeded the given time so I skipped the rest of demo and finished the presentation. I am looking forward seeing more interaction from the students with PalDev and I really think that the time when such events are being held by the students themselves is very near.

    A several suggestions came along with the presentation: some folks asked for advanced topics and this is very eligible and PalDev already has plans to do a bunch of advanced sessions for advanced users. Another asked for HOL’s but this is very limited due the limitation of available well equipped  labs.

    Hope that helps anyone


  • The Gu is Back!! with new Multilingual version!!

    Yesterday I checked my RSS feed and found that Scott Guthrie announced that he is starting a new series of posts. That was a great news to hear. Scott is one of the most popular Microsoft managers. He is one of those who played a core role developing Microsoft web platform even the whole .NET framework. He leads core .NET libraries,WPF, ASP.NET, ASP.NET MCV, Sliverlight and IIS teams.


  • Hosting Multiple websites/applications on IIS – Part 1

    IIS is the lonely web server –rather than web development server - in the Microsoft stack and the most recent one IIS7 add more flexibility, control and ease of use to IIS. There is a bunch of concepts need to be clear in mind when it comes to host information and pages on IIS to allow sharing then over the Internet, an intranet or an extranet. To host data you on IIS you will use websites, application and virtual directories. Those concepts was hanging around from previous versions.

    Sites, virtual directories, and applications

    Those three concepts is the building blocks you will use to host you websites, web applications, web pages and any other resources. In this post we will discuss the concept of website.


    So what is Website?

    A website (or web site) is a collection of related web pages, images, videos or other digital assets that are addressed with a common domain name or IP address in an Internet Protocol-based network. A web site is hosted on at least one web server, accessible via the Internet or a private local area network. – wiki-

    In IIS a A site is the top-level logical container that specifies how HTTP requests are received and processed - it defines a group of bindings that determine how the site listens for incoming requests, and contains the definitions of applications/virtual directories that partition the site's URL namespace for the purposes of structuring your application content. :) Thanks mike

    Ok this is what website means … oops! then it must map to physical folder, physical files, and resources ...etc? yes that’s right.

    IIS Default website Web servers works on a client server technology. In the simplest case this means that the client – usually web browser- requests a certain resources webpage, images ..etc from the web server e.g. IIS  using an http request. The web server picks up the request and maps it the appropriate website. In IIS there is a default website called Default Website which maps to C:\inetpub\wwwroot folder –inetpub is the default installation folder of IIS- We can add as many as websites we need but the main issue we need to address is that those websites should to be uniquely identified within the IIS server. Otherwise the web server -IIS- will no be able to redirect the incoming http requests to the correct website.

    Site Binding

    To uniquely identify website you will use site binding to configure Http.sys to listen on IP addresses and ports. Site binding includes two main attributes which is the binding protocol and the binding information. Okay so lets have a look to the DeafultWebsite site binding. Choose the default website> Edit Binding from DefaultSite context menu. As we can see: the binding protocol is http this means that the communication between the client and the server will occur over the http protocol. And we can see the binding information which consists of: IP address, Port and host header.

    Multipl host headers on website3

    What this means? this means that when a client requests your web server lets say that we have an intranet server called alpha by typing http://alpha in his browser the web server will pick up the request and maps its to the DefaultWebsite over the http protocol using any available IP address on port 80 which is the default port for http protocol.

    Ok,what if we need to have multiple website rather than the DefaultWebsite?

    As we stated above IIS is designed to host multiple websites by default each of them must be uniquely identified so to carry out we need to play with binding information parts:

    • IP address
    • TCP Port
    • Host Header

    The decision to which way you need to follow is determined in respect of your needs and available resources. Ok lets create additional three website to be host on our machine each to clarify this issue.

    Using IP address

    In IIS you can configure websites to listen to incoming http requests on all available IP address -unassigned- or on individual IP address. And by this you need to configure your website with certain IP address. Ok IIS> Sites> Add Web site and we need to fill the Site Name, Path, and in the binding information are type your certain website. Keep the other option as the same.

    This will add addional site in the IIS. The site configuration appears like this in the applicationHost.config file

    <site name="SiteBindingUsingIP" id="3">
    <application path="/" applicationPool="SiteBindingUsingIP">
    <virtualDirectory path="/" physicalPath="C:\SiteBindingUsingIP" />
    <binding protocol="http" bindingInformation="" />


    One disadvantage of this approach is that IP address is not always free to use. So assigning an IP address to every website may be a non eligible choice.

    Using Custom TCP Port

    We can change allow website to learn to a non-default TCP port rather than port 80 which is the default port of http protocol. What you need to do to accomplish this is the same of the previous step but you need to provide a unique and avail be TCP port. In the attached image the new site WebSite2 is using the same IP address of WebSite1 but on different port which 8080. 

    When users request the site they need to provide the TCP port after the name of the server or the IP address like this: http://sitename:PortNumber/ or http://IpAddress:PortNumber/. E.g. http://websit2:8080 or


    The main disadvantage of this method is that the users need to know on which port the website is working and append the TCP port to the website address and this not eligible on all case.

    Using Host Headers

    HTTP Host: headers are a feature of the HTTP v1.1 specification that allows a web server to host multiple web sites on a single IP address and TCP port, while simultaneously allowing HTTP v1.1 clients to specify the web site they wish to connect to. The process requires that the client send a Host: HTTP header as part of the HTTP request specifying a web site it wishes to access, and the web server having a web site configured with a corresponding HTTP Host: header value.

    Follow the same previous steps to define the website and fill the host header you need at the Host name field. You can change the TCP port but this will make no sense since host headers is enough to distinguish between websites on the same IP address.


    One website can have multiple hosting headers you can add more host headers by adding more bindings with different host names. To edit the site bindings Choose the desired site > Edit Binding and you can add/edit/and remove bindings. Multipl host headers on website3

    Clients could not be able to connect to the web server using host headers unless you those host headers are defined in the appropriate DNS Server or Host File. IIS is not a name resolution server its a web server so the mechanism how the users can contact your web server with the names you choose –host headers- is not the responsibility of the IIS server.

    Host Headers and SSL

    To use host headers with https a certain configuration should took a place. Until Windows 2003 SP1 IIS6 could not handle host headers over SSL. This is because that the host headers themselves are encrypted within the entire encrypted http request so when the http request is being received on the IIS it could not figure out to which website it should be redirected. After the SP1 IIS6 or by using IIS7 you can use wildcard certificates to handle host headers over https –we will  not go throw this process in this post-


    Hope this helps. In the next post we will have a look to Application Pool concept.

    Original post at PalDev


  • ASP.NET MVC 1.0 has been released

    Hello The Gu -Scott Guthrie- has announced the ASP.NET MVC 1.0. You can read the full post here. The amazing thing that ASP.NET MVC is an open source project and the code released under MS-PL licenses.

    And they say Microsoft does not support open source. They published  the source code of the .NET framework itself last year -but it was a closed source- and they now releasing open source projects. Who knows what future is hiding for us.

    Congratulation Microsoft!


  • Funny SSMS Error Message

    Hello All … today morning one of my collogues called me to check a problem in his machine when starting SQL Server Management Studio. This strange and funny error occurred after he installed windows updates. Anyway I could not understand the issue rather than solving it.


  • To Microsoft or not To Microsoft

    In 1600 Shakespeare wrote “To be or not to be, that is the question” in his famous and well know play “Hamlet”. I will twist this statement a bit “To Microsoft or not To Microsoft, that is the question”.

    Today while I was attending a workshop about business development I made a short conversation with one of the attendees – a freelance web developer- about Microsoft web development environment. He have a prejudgment says that using Microsoft tech’s costs a lot of money. He have no idea about the major move Microsoft did.

    What options I have as a freelancer, MicroISV … etc?

    What I tried to say that Microsoft provide developers with very impressive and powerful set of tools regardless the type of application –Web,Windows- . For example to develop a ASP.NET web application we can use:

    • Visual Web Developer Express Edition: a  full featured IDE to build AJAX-enabled web pages and  Data driven applications.
    • SQL Server Express: Simple and powerful database server.
    • Web Development Server : Small web server embedded with Web Developer Express.
    • ASP.NET and .Net Framework: Runtime and libraries  available with Windows operating system.

    You can start developing web applications using these tools without need to install big scale development stuff.

    What about other applications types?

    And while you are using these tools you will feel comfortable if you moved to develop windows applications for example. Microsoft provide developers with another set of tools for windows application development just like Visual C#,VB.NET,C++ Express. You will be using the same languages, the same frameworks, same libraries and a common IDE. 

    How it costs me when Microsofting?

    The nice about all the above that they are available free of charge. You don’t need to pay a penny for that stuff. That’s real their is no catch ups or hidden traps and another good news is you can use it to build commercial products.

    So you can start developing applications and make money without paying anything.

    Is their is any limitations?

    Yes, that’s for sure. These tools have limited features but I believe they are more than enough for developer with basic needs.

    Is that good for software development in Palestine?

    For sure. The Palestinian IT sector is still a growing one. People here have low living, limited finical resources, lake of opportunities and a weak economy. It’s hard enough for people to start up business in such circumstances. By using these tools you save your money to empower your business instead of spending large amount of money on buying software licenses.

    In a future post I will talk about another offer Microsoft provide students with. Until that time I hope that helps

    Huthaifa Afanah


  • Tips & Tricks: Details View and Read-only Fields

    One of the flexible and new features came with ASP.NET 2.0 was DetailsView control. This data bound control is used to display the values of a single record from a data source in an HTML table, where each table row represents a field of the record. The DetailsView control allows you to edit, delete, and insert records. In this post I will explain an issue related with Read-only data fields.


  • ASP.NET site crashed today!!

    Today while I am navigating through the Internet I visited the as usual. Then I moved to the site and surprise the ASP.Net site seems to have some problems. This problem seems to be solved very fast but I catch it. Notice the date and time below the image


  • Embedded Resources difference between VB.NET and C# projects

    While I am developing a custom web control to extend the default validation summary I used some images within this control. One of the nice features and solutions came with ASP.NET 2.0 to address this problem is using web resources. So I embedded these images in my custom control assembly and used the Page.ClientScript.GetWebResourceUrl to resolve their URL's.