Friday, June 4, 2010

Google Sitemap with Asp.Net C#

Step 1: Get a Google account
Step 2: Login to http://www.google.com/webmasters/sitemaps
Step 3: Add a website
Step 4: Verify that you are the owner by uploading an HTML file or add a Meta tag
Step 5: Add a sitemap for that website

Class will be as follows :

using System;
using System.Xml;

namespace shop.BLL.Utility
{
    public class SiteMapFeedGenerator
    {
        XmlTextWriter writer;

        public SiteMapFeedGenerator(System.IO.Stream stream, System.Text.Encoding encoding)
        {
            writer = new XmlTextWriter(stream, encoding);
            writer.Formatting = Formatting.Indented;
        }

        public SiteMapFeedGenerator(System.IO.TextWriter w)
        {
            writer = new XmlTextWriter(w);
            writer.Formatting = Formatting.Indented;
        }
        /// 

        /// Writes the beginning of the SiteMap document
        /// 
        public void WriteStartDocument()
        {
            writer.WriteStartDocument();
            writer.WriteStartElement("urlset");

            writer.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap/0.84");
        }

        /// 
        /// Writes the end of the SiteMap document
        /// 
        public void WriteEndDocument()
        {
            writer.WriteEndElement();
            writer.WriteEndDocument();
        }

        /// 

        /// Closes this stream and the underlying stream
        /// 
        public void Close()
        {
            writer.Flush();
            writer.Close();
        }

        public void WriteItem(string link, DateTime publishedDate, string priority)
        {
            writer.WriteStartElement("url");
            writer.WriteElementString("loc", link);
            writer.WriteElementString("lastmod", publishedDate.ToString("yyyy-MM-dd"));
            writer.WriteElementString("changefreq", "always");
            writer.WriteElementString("priority", priority);
            writer.WriteEndElement();
        }
    }
}

 


This is just a basic Google Sitemap, you can add elements for geographic info about the item or mobile sitemaps etc. You can find more info for that on:  http://www.google.com/support/webmasters/bin/answer.py?answer=34657


You can use this class in an .aspx or .ashx file. I used an .aspx in the following (code behind) sample:


protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.ContentType = "text/xml";
        shop.BLL.Utility.SiteMapFeedGenerator gen = new shop.BLL.Utility.SiteMapFeedGenerator(Response.Output);
        
        gen.WriteStartDocument();
        gen.WriteItem("http://www.mysamplesiterocks.com/Default.aspx", DateTime.Now, "1.0");
 gen.WriteEndDocument();
        gen.Close(); 
    }

Tuesday, May 4, 2010

Must have Internet Explorer add-on for developers

Developer uses tools to make life easier. One such tool is Web Development helper. This is one of the best tool ever designed.
It has several common features:

    * DOM inspector
    * Screen capture
    * Page details viewer
    * Script debugging with script console and script class viewer
    * Immediate window

And a few helpful ASP.NET related features:

    * ViewState viewer that show information in raw, decoded, and parsed forms
    * Show trace information
    * View and manage cache
    * Restart application

One of its feature, HTTP Logging, logs HTTP and HTTPS requests initiated by the browser or Ajax scripts. It provides all the information about Ajax postbacks shown under request and response details. That means We can actually see the information that is sent to the server and can see the markup or JSON objects that are sent back to the client.

Web Development helper works with IE version 6 and above, and is completely free. It requires .NET Framework 2.0 to be installed.
You can see more details and download this tool from Nikhil's Website.

Thursday, March 18, 2010

Microsoft releases SDK for Facebook

Microsoft has released a software developer kit for FACEBOOK that'll allow developers to create facebook like applications for Silverlight and WPF (Windows Presentation Foundation). This'll help developers to build social application in much more easier manner.











This SDK is having samples, tools, source code for API, components, controls to develop FACEBOOK application in ASP.NET, Silverlight, WPF, and WinForms.

If you're interested in taking a look, you can download the SDK here.

Tuesday, March 16, 2010

Talk about offshoring??

In today’s world, for the software industry – ‘Offshoring’ and ‘Outsourcing to India’ – are synonyms. So if somebody is talking about offshoring, they are basically talking about outsourcing to India unless specified otherwise. Not to say that things are not changing – there are other countries like China and Vietnam who are picking up more and more work from the US. But they still have a long way to go because of the unique advantages that India has.
But, to SeaCode Inc, offshoring means three miles off the coast of the US. What San Diego-based start-up SeaCode Inc. plans to do is nothing if not novel: anchor a cruise ship three miles off the coast of Los Angeles, fill it with up to 600 programmers from around the world, eliminate visa restrictions and make it easy for customers to visit the site via water taxi.
I won’t make a comment on whether they will be successful or not – since I am not yet clear if this is their entire business model or have they refined it further. But this idea is definitely interesting. Read the story here.