Wednesday, May 31, 2006

Hello all...

After long evening of "Mangaling" and mingling at company party in 'GolfiTech' Tel Aviv yesterday, I came up to work this morning and decided to share you with Master Page working.

In the current project that we are working on, we are using MasterPage (new feature in asp.net 2.0). This is a great control that does the work like 'header' and 'footer' user controls, for an example, (that are customied by the user), it comes to let us better and easier unified design to all (ao some of) the application pages.

Good tutorials and example how to create Master Page you can find: here.

And now to the issue of this post. In some of the application that I am working on, in addition to the super master page, there is a nested one. Now, when I tried to get the control (from the server side ofcrouse) that sits in the nested master page I couldn't find it, and this was a problem ofcourse... :)

The solution is to go up until you reach the super master page and after it to go down to the nested master page where the control is. The syntax is:

Page.Master.Master.FindControl("<Container Name>").FindControl("<Control Name>");

Where the <Container Name> is the placeholder that holds the page.

Hope this will help someday...

Posted by: Eran Nachum (c)
Post Date: 5/31/2006 8:32:55 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | | Trackback   #
 Sunday, May 28, 2006

Hi!

In this post, I will examine several different approaches to work properly against web services. I will explain the question (or problem, you can define it however you want) from the real life: You are working on an HR registration application and you want to register a new employee to the system, but the DB that holds all the employees details is located in remoted server. The actions that the application need to do are:

  1. Check if the username is already exist in the repository of contents (first WS).
  2. Register the user and save her details to the system DB (second WS).
  3. Send a registration information to the user that all her details has been feed (third WS).

As we saw, every WS will do a single action, and the last 2 ones are dependent each other.

Now, the question that is being asked is how to handle those actions in exceptions cases, should I want to roll back or to complete the whole bunch of actions.

The approaches are:

  1. Repeated requests handling: This way handles the situation that the request is already has been sent to the remote server (by web service ofcourse), and we will want to know if the request handling is over. The way is to attach transaction indetifier to the request. By that, if the server is still busy (while processing the resuest), it will send an appropriate message to the client (status ID). This solution comes to prevent duplicates mesaages requests to the server. One more thing... when implementing this sulotion, you need to consider and to support large number of transcactions (for further cases). By that, the client needs to know the ID of the transaction before sending the request to the server.
  2. Two-Phase commit: Before I start speaking the solution, I will explain this term: The two-phase-commit protocol is a distributed algorithm which lets all nodes in a distributed system agree to commit a transaction. The protocol results in either all nodes committing the transaction or aborting, even in the case of network failures or node failures. Now, the common approach, claims that algorithm is not "healthy" to use when working over web services, because if the web service is fails (or shuts down) in a middle of a transcation, there is a chance that the remote server won't know to send a message regarding the transaction state. The solution recommended here is to devide BIG transaction(s) to small transactions, when every small transaction will be handled by one web service. One more important thing is to plan properly the transactions flow, to prevent as much as minimum loss of data (if accured). I recommend to execute each action over one web service, and to call to a transaction manager web service that will be responsable to all the web services actions.
  3. Queued Processing: This approach claims that as long as the request is OK (no exception has been received), we will assume that action has been completed properly. To implement this approach you need to create a requests' queue (the requests that we will want to execute). Now, if no exception has been received, the queue will continue executing the further ones. If an exception has been received, the mechanism will roll back the related requests.
  4. Transaction Locking: When calling a web service (which is a part of a transaction), all its related resources will be locked in purpose not to allow other users to execute it. Real life example is withdrawaling cash from an ATM. When the user withdrawals the money from the machine, the transaction and his related data in the database is being locked, to prevent mismatch.

In summary, I spread here 4 different approaches to handle transactions over web services. I will be glad to have some comments if you have some.

Wellness untill next time, see you...

Posted by: Eran Nachum (c)
Post Date: 5/28/2006 8:22:55 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | | Trackback   #
 Wednesday, May 24, 2006

Hello all again...

Some monthes ago, while reading professional tutorials, I encountered with a nice implementation (maybe some of you encountered it before, but I think this is a nice syntax to know) and it called Smart Indexer of a specific object.

Look at the example below:

class EranEntity
{
   private Hashtable qualities = new Hashtable();

   // Indexer (i.e. smart array) 
   public object this[string key]
   {
      get { return qualities[key]; }
      set { qualities[key] = value; }
   }
}

Here, I've created new class called, 'EranEntity' and it contains a Hashtable that holds all of my qualities (and I have a lot of it, as you know... :)). By building this property, it will be much easier to get quality or to update one using 'Dictionary' - the interface is much more readable and easier to use.

Now, lets set some qualities:

public static void Main()
{
   // Create EranEntity instance
   EranEntity entity = new EranEntity();

   entity["smart"] = "very good…";
   entity["nice"] = "very nice…";
}

Today in the new world of terms of .NET 2.0, we can also implement this genericly using the new Generics mechanism.

p.s.

Another thing, there is a VS. 2005 quick shortcut to do it by typing the word: indexer (in the editor ofcourse...) and clicking the Tab key until the whole bunch of code is being generated for you to edit.

 

See you for now...


 

Posted by: Eran Nachum (c)
Post Date: 5/24/2006 7:54:13 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | | Trackback   #
 Monday, May 22, 2006

Hello all!

This is my first blog's post, I am thrilled to start writing my thoughts, and I have a lot of them (I think....).

In my first post, I will go into details of 'Publish website in .NET 2.0', this issue is different and renewed then .NET 1.1 - there are several new issues that someone that is not familiar with .NET 2.0 will be glad to hear, so lets start...

As known, publishing web application under visual studio 2005 platform is different than publishing the same application under visual studio 2003 platform.

In VS 2003, when we had wanted to deploy a site (web application) to production area, we had need go to the Project tab and select the Copy Project option, this action had gathered all the web site execution's necessery files and copied it to a new folder.

In VS 2005, we got some innovations that gives us several alternatives to deploy web site to production area. The main action to deploy a web application to deployment is Publish, to do this you need to mark the web site project, press the right button and choose Publish Web Site. When you do this action, the application will be precompiled and it will be saved in the specified folder that you noted.

Other actions that you can determine while doing the publish action are:

  1. Allowing the precompiled web site to be updatable - by marking this checkbox, all the ASPX files with their markup intact as well, will be precompiled into a single DLL (under the /bin folder), that represents it.
  2. Using fixed naming  and single page assemblies - choosing this action and the former one, will create a single DLL file to each ASPX file.
  3. Enabling string naming on precompiled assemblies - by choosing this option, you will need to give strong name to the generated assembly(ies), this name (key) will deffer it from newer same name assemblies that precompiled with no strong name or without any.
  4. Lastly, if you will publish the web site with none of the checkboxes selected, a single DLL will be created with no markup of the ASPX files and compiled metadata files for each ASPX file.


These actions will be pointed to the aspnet_compiler tool. This tool, supplies a creation of debugging symbols, but this action will not be able to happen from publish action, because if supplies precompilation in release state without symbols. (You can read more about aspnet_compiler here: http://odetocode.com/Articles/417.aspx).

In order to attach symbols to to web application, there is new tool named: Web Site Deployment (WSD). You can download it from this address: http://msdn.microsoft.com/asp.net/reference/infrastructure/wdp/default.aspx. This tool adds several compilations configurations in release and degub mode.

In a nutshell, the steps of adding symbols by this tool are:

  1. Mark the web site application, right click on you mouse and choose the Add Web Deployment Project option.
  2. Select the name and the location of the web site to deploy.
  3. Now, a deployed project had been added to you solution! Mark it and by right clicking, select the Property pages option.
  4. Mark Generate debug information and finish.
  5. Build the whole application.

After these actions, a new folder with the given name by you will be created, and symbols will be 'stuck' to the application. (Real life example is: In the production server, you can see the souce code line while a runtime error will happen, good thing right...?)

Related links are:

http://download.microsoft.com/download/1/5/4/1541980a-d8fc-407b-8c9f-c2df5445b041/Using%20web_deployment_projects_final.doc

Good article about this post: http://odetocode.com/Blogs/scott/archive/2005/11/15/2464.aspx

That's it for now. I will be glad to hear your comment about this (this is my first one, don't forget).

See you here...

 

 

Posted by: Eran Nachum (c)
Post Date: 5/22/2006 8:37:57 AM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | | Trackback   #