Wednesday, June 16, 2010

Cookieless Session and Google Indexing (Googlebot)

Hi,

Today I'm discussing one of the challenging problem that I come across during my 5+ years of career.

All of you must be developing website and these websites are automatically indexed by Google crawler named Googlebot. I was working on one of an e-commerce website which is developed in ASP.NET 3.5. It was previously developed in PHP and all of their pages were already crawled. After releasing 1st version we came to know that Google is not crawling our new pages. Though SEO is very vast area and genuinely I never involed in this process because we had an SEO experts in past who look after for this. But ththis time case was different and we didn't have any SEO expert. So I need to jump into it to findout what's wrong with the website and why Google is not able to crawl a new website pages.

So googleing for some time we just came to know my website was using forms authentication for user authentication purpose. If you remember web.config has one parameter named cookieless which we need to set either to AutoDetect or UseCookies to allow or disallow cookieless sessions. I had previously it was set to AutoDetect hence was appending session ids in the URL if u connect through cookieless browsers. Now when Googlebot tries to connect to website for crawling it was identified as Cookieless browser by ASP.NET engine and hence session id was appending in URL itself and 302 response was sent. That's was the issue because of Google was not able to index the new pages.

Possible Solutions:

1. The easiest solution to the problem is to stop using ASP.NET's AutoDetect session mode.

2. If you need to use that feature though, you simply can configure ASP.NET to recognize Google's spider as supporting cookies. This article shows how. (http://www.kowitz.net/archive/2006/12/11/asp.net-2.0-mozilla-browser-detection-hole.aspx)

3. You can implement automatic support for URL-based sessions yourself. This takes some time to implement, and the benefits may not be worth the implementation cost. It works like this:
- you use cloaking to generate session IDs if the visitor is not a web spider
- start generating session IDs only when the session is really needed for tracking (for example, after the visitor adds items to his or her shopping cart). This way you don't feed your users with URL-based session IDs unless you really need to.

Happy Programming!!!

References:

http://www.seoegghead.com/blog/seo/aspnet-20-setting-dangerous-for-google-indexing-p217.html
http://www.kowitz.net/archive/2006/12/11/asp.net-2.0-mozilla-browser-detection-hole

Tuesday, January 12, 2010

JQuery based TreeView

Hello All,

Please follow the link for Jquery based tree

http://www.jstree.com/

Features at a glance:


  • Various data sources - HTML, JSON, XML
  • Supports AJAX loading
  • Drag & drop support
  • Highly configurable
  • Theme support + included themes
  • Numerous callbacks to attach to
  • Optional keyboard navigation
  • Maintain the same tree in many languages
  • Inline editing
  • Open/close optional animation
  • Define node types and fine tune them
  • Configurable multitree drag & drop
  • Optional multiple select
  • Search function
  • Supports plugins & datastores
  • Optional state saving using cookies
Currently supported browsers are:

  • Internet Explorer 6+
  • Mozilla Firefox 2+
  • Safari 3+
  • Opera 9+
  • Google Chrome
 Happy Programming!!!

Alternative of Cursor in SQL

Hello Friends,

We know that how cursors are useful in SQL server and we know its drawback even as it consume lots of resource like RAM, Disk space, network bandwidth etc. Don’t think too much here is answer of your question of Alternative of Cursor in SQL. Please go through link below written by Mr. Vinodkumar.


Happy Coding!!!

Script to generate Create Index Scripts for all indexes in table

In most of the cases we design the database first and then we create the indexes. We had a need to provide scripts for all indexes in the tables. Following is the script to generate scripts for all non clustered indexes.

-- Get all existing indexes, but NOT the primary keys
DECLARE cIX CURSOR FOR
SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID
FROM Sys.Indexes SI
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC ON SI.Name = TC.CONSTRAINT_NAME AND OBJECT_NAME(SI.Object_ID) = TC.TABLE_NAME
WHERE TC.CONSTRAINT_NAME IS NULL
AND OBJECTPROPERTY(SI.Object_ID, 'IsUserTable') = 1
ORDER BY OBJECT_NAME(SI.Object_ID), SI.Index_ID

DECLARE @IxTable SYSNAME
DECLARE @IxTableID INT
DECLARE @IxName SYSNAME
DECLARE @IxID INT

-- Loop through all indexes
OPEN cIX
FETCH NEXT FROM cIX INTO @IxTable, @IxTableID, @IxName, @IxID
WHILE (@@FETCH_STATUS = 0)
BEGIN
DECLARE @IXSQL NVARCHAR(4000) SET @IXSQL = ''
SET @IXSQL = 'CREATE '

-- Check if the index is unique
IF (INDEXPROPERTY(@IxTableID, @IxName, 'IsUnique') = 1)
SET @IXSQL = @IXSQL + 'UNIQUE '
-- Check if the index is clustered
IF (INDEXPROPERTY(@IxTableID, @IxName, 'IsClustered') = 1)
SET @IXSQL = @IXSQL + 'CLUSTERED '

SET @IXSQL = @IXSQL + 'INDEX ' + @IxName + ' ON ' + @IxTable + '('

-- Get all columns of the index
DECLARE cIxColumn CURSOR FOR
SELECT SC.Name
FROM Sys.Index_Columns IC
JOIN Sys.Columns SC ON IC.Object_ID = SC.Object_ID AND IC.Column_ID = SC.Column_ID
WHERE IC.Object_ID = @IxTableID AND Index_ID = @IxID
ORDER BY IC.Index_Column_ID

DECLARE @IxColumn SYSNAME
DECLARE @IxFirstColumn BIT SET @IxFirstColumn = 1

-- Loop throug all columns of the index and append them to the CREATE statement
OPEN cIxColumn
FETCH NEXT FROM cIxColumn INTO @IxColumn
WHILE (@@FETCH_STATUS = 0)
BEGIN
IF (@IxFirstColumn = 1)
SET @IxFirstColumn = 0
ELSE
SET @IXSQL = @IXSQL + ', '

SET @IXSQL = @IXSQL + @IxColumn

FETCH NEXT FROM cIxColumn INTO @IxColumn
END
CLOSE cIxColumn
DEALLOCATE cIxColumn

SET @IXSQL = @IXSQL + ')'
-- Print out the CREATE statement for the index
PRINT @IXSQL

FETCH NEXT FROM cIX INTO @IxTable, @IxTableID, @IxName, @IxID
END

CLOSE cIX
DEALLOCATE cIX


Happy Programming!!!
Cheers