Monday, October 6, 2008

Microsoft Web Platform Installer -- All in one.


Microsoft has published`"Microsoft Web Platform Installer Beta" an installation package that combines all services required to run an asp.net web application. The package includes IIS7, Visual web developer 2008 express edition and sqlserver 2008 express edition. The bad news is that the package run only on Windows Vista RTM, Windows Vista SP1, Windows Server 2008 which is normal since IIS7 runs on these platforms. However that would make the package more valuable for hosting companies than it's for developers.I think such packages should be targeted for beginner developers who are not yet aware of all components they need to start developing for dotnet and save them from setup hassle for many components.

Friday, August 22, 2008

Is't true that Asp.net gets no respect ?

Rick Strahl had a good article named ASP.NET gets no Respect regarding asp.net.The article discusses many points including :

- why many developers don't choose asp.net as their web technology?
- what makes asp.net a different web technology?
- Is asp.net is just being hated because it's a microsoft product?

The article is a great one to give you an insight on what is going on out there. Regardless of my loyalty to microsoft technologies I can't stop thinking of a question that every web developer maybe asking :

Do I need to learn a backup web technology?

Friday, August 15, 2008

I HAD A WAR WITH A checkbox

Have you created a gridview with a checkbox template field. sure you have if not just jumb to that nice article on how to do and that article to know how to implement Check All and Uncheck All functionality but don't forget to come back, am waiting.As you all know the main idea is to save round trips to the server by selecting multiple checkboxes and take an action on the selected rows.So why I had that war since everything seems just cool and under control.The problem was that each time I check the checkbox it returns false on the server side which drive me crazy "Why, why, why ....".However after many trials reviewing the javascript for attaching the event to the checkbox I found myself searching in the wrong part of the city so I got back to the server side where I found my terrible mistake "in that case off course". I was binding the Grodview control each time the page was loading "what was I thinking of, Nothing I guess and That was the problem :D". Anyway It seemed so natural why the checkbox always returned false since it had just been created.To Summary the long story The !IsPostBack check was the solution.

Friday, May 23, 2008

Bolggers need this

Are you a blogger ? Are you a technical blogger ? Have you faced difficulties pasting your code in to your post???

For me, all the above is just true. AS am using blogger I faced that problem when trying to paste some c# code into one of my posts.The problem came from the html validation that blogger makes.So whenever you have some html character like "<,> and &" you will need to html encode them otherwise you will get an error. Postable is a simple site allowing you to paste your code and generates a friendly output code by converting all the special characters to their HTML Encodes. After converting your code using Postable you would probably use the <code> tag to distinguish your post text from your code.

Saturday, May 3, 2008

Kayak != Kayak API

Have You used Kayak, You should. As I was surfing the web I was refered to a kayak web site. Kayak provide search services for Flights"most interesting", Hoteles, Cars and Cruises. I really enjoyed the flight search on It. Not only did I enjoy the data it returns but also the way it graps and displays it. Suddenly I remembered I am a developer, really :D . I have to look to the other side of the picture, which is ?!?!?! You are right API. Any site or entity have a valuable huge set of data must have an API or webservice to expose it to developers, I said to myself. So I start looking for that API. I expected to see it in the Labs section but I didn't. So with a simple Google search I found that Kayak API . Unfortunatly Their API is not as much accurate nor reliable as their service.The Api has some limitations like it allows only 1000 request per day spreaded over the day which means 41 request per hour. Moreover the system is not reliable "not yet", when you see this error "anonymous access to kayak API denied"don't panic. There is one way to solve that problem which is acquire your token "developer key" when you are logged in other wise the key won't be valid. if you do so and still get this friendly error "you are gonna see a lot" just keep making requests cause they seem to have a problem with sessions.

Anyway, since I spent a couple of hours traying to get familiar with the system I decided to share it with you.

The API is so simple, just send few GET HttpRequest and Handle the Xml response.The squencve is as follows:

- Send request with the developer key to get the sessionID.
- Make another request using that sessionID to get the searchID.
- Make last request using both sessionID, searchID and search criteria in the query string.

The Url for each request and query string paramaters are documented in the API Specs .

Here is a simple page with a gridview and a button to grab some data using this API. I didn't consider error handling in the code since you all can do. This is a very simple implementation for the API to be able to get started.

You will need to change the DEVELOPERKEY in the first url with the key you get from the site.




using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net;
using System.IO;
using System.Xml;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

string xmlResult = MakeRequst("http://api.kayak.com/k/ident/apisession?token=YOUR TOKEN");
string sid = GetRequiredId(xmlResult, "sid");

xmlResult = MakeRequst("http://www.kayak.com/s/apisearch?basicmode=true&oneway=n&origin=BOS&destination=SFO&destcode=&depart_date=05/09/2008&depart_time=a&return_date=05/13/2008&return_time=a&travelers=2&cabin=b&action=doflights&apimode=1&_sid_=" sid);
string searchId = GetRequiredId(xmlResult, "searchid");

xmlResult = MakeRequst("http://www.kayak.com/s/basic/flight?searchid=" searchId "&c=10&apimode=1&_sid_=" sid);

List<Leg> legs = GetAllLegs(xmlResult);

if (legs != null)
{
GridView1.DataSource = legs;
GridView1.DataBind();
}

}
//Get sessionId and searchId
private string GetRequiredId(string xml, string idName)
{
string id = "";
XmlDataDocument doc = new XmlDataDocument();
doc.LoadXml(xml);
XmlNodeList nodes = doc.GetElementsByTagName(idName);
if (nodes != null && nodes.Count > 0)
id = nodes[0].InnerText;
return id;
}

//Make required request
private string MakeRequst(string requestUrl)
{
System.Net.HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUrl);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();

StreamReader reader = new StreamReader(stream);
string xmlText = reader.ReadToEnd();

return xmlText;

}

//Get a list of Leg objects.
private List<Leg> GetAllLegs(string responseXml)
{
XmlDataDocument doc = new XmlDataDocument();
doc.LoadXml(responseXml);
List<Leg> legs = new List<Leg>();
XmlNodeList legNodes = doc.GetElementsByTagName("leg");
foreach (XmlNode legNode in legNodes)
{
Leg leg = new Leg();
for(int i=0;i<legNode.ChildNodes.Count;i )
{
if (legNode.ChildNodes[i].Name == "airline_display")
leg.AirLine = legNode.ChildNodes[i].InnerText;
else if (legNode.ChildNodes[i].Name == "orig")
leg.Origin = legNode.ChildNodes[i].InnerText;
else if (legNode.ChildNodes[i].Name == "dest")
leg.Dest = legNode.ChildNodes[i].InnerText;
else if (legNode.ChildNodes[i].Name == "depart")
leg.Depart = Convert.ToDateTime(legNode.ChildNodes[i].InnerText);
else if (legNode.ChildNodes[i].Name == "arrive")
leg.Arrive = Convert.ToDateTime(legNode.ChildNodes[i].InnerText);
else if (legNode.ChildNodes[i].Name == "stops")
leg.Stops = Convert.ToInt32(legNode.ChildNodes[i].InnerText);
else if (legNode.ChildNodes[i].Name == "duration_minutes")
leg.Duration = Convert.ToInt32(legNode.ChildNodes[i].InnerText);
else if (legNode.ChildNodes[i].Name == "cabin")
leg.Cabin = legNode.ChildNodes[i].InnerText;
}
legs.Add(leg);
}
return legs;
}
}

// Leg class represents part of the returned XML
class Leg
{
private string airLine, origin, dest, cabin;
int stops, duration;
private DateTime depart, arrive;
public string AirLine
{
get { return airLine; } set { airLine = value; }
}
public string Origin
{
get { return origin; } set { origin = value; }
}
public string Dest
{
get { return dest; } set { dest = value; }
}
public string Cabin
{
get { return cabin; } set { cabin = value; }
}
public int Stops
{
get { return stops; } set { stops = value; }
}
public int Duration
{
get { return duration; } set { duration = value; }
}
public DateTime Depart
{
get { return depart; } set { depart = value; }
}

public DateTime Arrive
{
get { return arrive; }
set { arrive = value; }
}
}

Friday, May 2, 2008

Godaddy + Windows + IIS7 = PHP

My last article about godaddy windows hosting seemed to attract somebody in godaddy so they respond to the post sending me a comment on windows hosting plans on godaddy regrading PHP.So to be honest I have to redirect readers to this article to get Godaddy point of view. After all everybody is a winner from a better service.

Regards,

Tuesday, April 29, 2008

Want to Install Wordpress on Godaddy ? You won't ...

Last night I spent few hours trying to install the 5 minutes installation wordpress on godaddy windows hosting but all was in vain. So I gave up and decided to email their customer support asking what's is wrong "after all I did all configurations required". Their response came with a surprise " Godaddy no longer supports PHP scripting on windows hosting ". The solution is to upgrade/downgrade your hosting plan to linux . I did upgrade to linux hosting "what would work better with PHP, They are a family !!!" . Anyway guys no more PHP CMSs on godaddy windows hosting So save your time or just look for other hosting if you are such a windows loyal.

Regards,

Thursday, April 24, 2008

.NET really ROCKS

2 days ago while reading some topics in my google reader I found a cool link to .net rocks. To be honest, that was the first time I visit the site and even knowing of its existance. Knowing that It has been there since 2002 shocks me "How this is myfirst time to see that cool site?!!, I guess I need to get out more". So I thought of blogging it to those who are just like me and didn't know about It. .Net Rocks introduces weekly podcast talk in .net and related topics. The interesting thing about it is that its fun and technical at the same time. I even thought to download the talks on my MP3 and listen to them while driving, that came after subscribing to the site feed which provide the talks directly to my RSS reader.

Tuesday, March 11, 2008

Microsoft IE8 - Will we make a new css file or just using some hacks??

Microsoft had realsed IE8 Beta1 for developers and designers.It comes with new features especially for developers and designers. What I was excited about was The ability to Emulate The IE7 whenever you want.Another cool feature is the ability to view your site in Ie5,Ie7 and IE8 which is a cool feature when developing as you can check the compatibility of your CSS with those versions. You can go and discover more.

http://www.microsoft.com/windows/products/winfamily/ie/ie8/getitnow.mspx