Keyboard Face

when you find QWERTY imprinted on your cheek - it's time to go to bed.

Tags

asp CSS css menus dreamweaver flash gallery2 hosting iis7 Javascript jquery jquery ui left mac mssql os9 php printer rdp SEO sql sql server windows wordpress

Is ASP.NET Viewstate bad for SEO?

June 13, 2007 by Tom 3 Comments

One of the features of ASP.NET is that it remembers the state of controls that are on the page throughout the page cycle. It does this automatically for you by creating a hidden field called Viewstate.

This field can often times become very large. This can impact SEO because search engine bots don’t like to wade through lots of code to get to the content. Many SEOs will tell you to optimize your code so as to remove all needless HTML, Javascript and CSS from the page and to use external files whenever possible.

I researched this recently and found a good forum thread on this topic.


http://www.webmasterworld.com/forum47/2044.htm

It goes into several methods for working around ASP.NET’s viewstate for SEO.

The first is to disable viewstate all together:

< %@ Page EnableViewState="false" %>

or

remove the runat=server attribute of the form tag. (I have not tried that)

The second is to minimize the size of the viewstate field by removing the runat=server attribute of all controls you don’t need to remember their state.

The last thing they recommended was to move the viewstate field to the bottom of the page. There is some code there that supposidly did this, but I haven’t tried it. Keep in mind that the post is dated 2004 so I don’t know if it willl work without bugs in ASP.NET 2.0

Here is the excerpt from the post:

Actually…I just found the code in the DNN project…they use it in a base page…if you are not familiar with that it is a class that inherits from Inherits System.Web.UI.Page and then any page you make should inherit from your custom base page. You could also probably copy and past the below code into each of your pages.
' This method overrides the Render() method for the page and moves the ViewState
' from its default location at the top of the page to the bottom of the page. This
' results in better search engine spidering.
'
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Dim stringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim htmlWriter As HtmlTextWriter = New HtmlTextWriter(stringWriter)
MyBase.Render(htmlWriter)
Dim html As String = stringWriter.ToString()
Dim StartPoint As Integer = html.IndexOf("&lt;input type=""hidden"" name=""__VIEWSTATE""")
If StartPoint />= 0 Then 'does __VIEWSTATE exist?
Dim EndPoint As Integer = html.IndexOf("/>", StartPoint) + 2
Dim ViewStateInput As String = html.Substring(StartPoint, EndPoint - StartPoint)
html = html.Remove(StartPoint, EndPoint - StartPoint)
Dim FormEndStart As Integer = html.IndexOf("") - 1
If FormEndStart >= 0 Then
html = html.Insert(FormEndStart, ViewStateInput)
End If
End If
writer.Write(html)
End Sub

Filed Under: ASP.NET, SEO

MSSQL Table Size for all tables

June 12, 2007 by Tom 7 Comments

As far as I could tell there was no easy way to query MSSQL to get a list of all of its tables and their respective sizes. I wrote a sql script that does this for you.

It’s below:

declare @RowCount int, @tablename varchar(100)
declare @Tables table (
PK int IDENTITY(1,1),
tablename varchar(100),
processed bit
)
INSERT into @Tables (tablename)
SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'BASE TABLE' and TABLE_NAME not like 'dt%' order by TABLE_NAME asc

declare @Space table (
name varchar(100), rows nvarchar(100), reserved varchar(100), data varchar(100), index_size varchar(100), unused varchar(100)
)
select top 1 @tablename = tablename from @Tables where processed is null
SET @RowCount = 1
WHILE (@RowCount <> 0)
BEGIN
insert into @Space exec sp_spaceused @tablename
update @Tables set processed = 1 where tablename = @tablename
select top 1 @tablename = tablename from @Tables where processed is null
SET @RowCount = @@RowCount
END

update @Space set data = replace(data, ' KB', '')
update @Space set data = convert(int, data)/1000
update @Space set data = data + ' MB'
update @Space set reserved = replace(reserved, ' KB', '')
update @Space set reserved = convert(int, reserved)/1000
update @Space set reserved = reserved + ' MB'

select * from @Space order by convert(int, replace(data, ' MB', '')) desc

Filed Under: SQL Server

Javascript not loading using AJAX for ASP.NET

May 23, 2007 by Tom Leave a Comment

Microsoft came out with an AJAX library for use with ASP.NET 2.0. They have a great support website located at ajax.asp.net. Lots of great videos and it works easily when you create a new website from scratch.

I ran into trouble when trying to use their AJAX library with an existing website. It wouldn’t give me any errors, the javascript just wouldn’t work with any of the AJAX controls. It was as if the AJAX didn’t exist!

After about an hour of searching and head scratching I figured that it must be web.config’s fault. I found a page that talks about updating your web.config for integrating the AJAX library into your site. Here it is:

http://ajax.asp.net/docs/ConfiguringASPNETAJAX.aspx

I followed all the directions and like magic, my site works with AJAX now! Phew.

Filed Under: AJAX, ASP.NET

  • « Previous Page
  • 1
  • …
  • 20
  • 21
  • 22
  • 23
  • 24
  • …
  • 41
  • Next Page »

Pages

  • About Me
  • WordPress Permalinks in IIS using Custom 404 Redirect

Archives

  • May 2019
  • February 2019
  • January 2018
  • May 2016
  • April 2016
  • December 2015
  • November 2015
  • May 2015
  • April 2015
  • January 2013
  • March 2012
  • February 2012
  • December 2011
  • September 2011
  • August 2011
  • November 2010
  • October 2010
  • June 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • September 2009
  • August 2009
  • July 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • November 2008
  • September 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • December 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • January 2007
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • May 2005

ASP.NET Resources

  • Keven Roth’s Code Library
  • Lemon Law

Blogroll

  • Arin Morfopoulos
  • Jamie
  • Physical Therapists

Code Search Engines

  • Koders
  • Krugle

CSS & Design Resources

  • CSS Basics

Other

  • Amazon
  • Car Repair Questions
  • Cool Quizzes
  • Delphi LA
  • Physical Therapy Clinic Directory
  • Quickbooks Questions
  • Secret Santa Game

Site\'s I\'ve Designed or Helped With

  • Area Rugs
  • Dental Implants
  • Dental Website Design
  • FHA Loans
  • Secret Santa Gift Ideas