Moving the viewstate Id

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
harris43
Lieutenant (LT)
Lieutenant (LT)
Posts: 64
Joined: Fri Oct 13, 2006 12:17 pm

Moving the viewstate Id

Post by harris43 » Wed Aug 06, 2008 7:58 am

I was looking at the source code for a typical product page and noticed that one of the first things inside the body tag was this VIEWSTATE Id tag that's a like a mile long. I need to move that to the bottom of the body tag if that won't cause any issues. I'm assuming this is in the product.aspx page some place.

Will this cause any issues? Can I move those other javascript tags to the bottom too?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Moving the viewstate Id

Post by mazhar » Wed Aug 06, 2008 8:54 am

I think you are are viewing the HTML source in browser, are you?
VIEWSTATE is handled by ASP.NET and you must never change it and simlarly most of the javascript is emitted by ASP.NET controls. Any how changing this can cause undesirable results so better avoid it

harris43
Lieutenant (LT)
Lieutenant (LT)
Posts: 64
Joined: Fri Oct 13, 2006 12:17 pm

Re: Moving the viewstate Id

Post by harris43 » Wed Aug 06, 2008 9:43 am

don't want to change it.
I just want to move it. The lower it is, the higher my relevant content is. Google likes this.

Moving it would cause a problem?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Moving the viewstate Id

Post by jmestep » Wed Aug 06, 2008 5:27 pm

If it can't be moved- I think .net just generates it-- you might want to do something like the following for meta tags. I did this and put my Description in the META description, and that is what Google is picking up to show in the summaries for the links.
viewtopic.php?f=42&t=7489
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: Moving the viewstate Id

Post by afm » Wed Aug 06, 2008 5:57 pm

It can be moved to the bottom of the page. Search Google for "HttpModule ViewState" and you will find several. A few years ago I even wrote one.

Unfortunately, moving viewstate to the bottom of the page has a side effect. As you noticed, the viewstate element can be quite big. If you move it to the bottom, the browser might render the top of the page before the viewstate element is rendered. If the top of the page includes an element that causes a postback and if the person at the other end of the line clicks on that element before the viewstate is loaded, then the viewstate in the postback will not match the viewstate that the server sent and ASP.NET will throw an exception.

This happens more frequently than you might imagine. After several invalid viewstate exceptions, I decided to leave viewstate at the top of the page.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: Moving the viewstate Id

Post by afm » Wed Aug 13, 2008 7:23 pm

As a followup, the .NET Framework 3.5 Service Pack 1 includes a new setting to force all of the hidden fields to the top of the form (prior to this ViewState was at the top, but EventValidation was near the bottom I think).

MS added the option to fix the validation error that occurs if a postback is made before the page fully rendered.

See "Update for viewstate issues" on the ASP.NET Debugging blog.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: Moving the viewstate Id

Post by Logan Rhodehamel » Mon Aug 18, 2008 12:50 pm

afm wrote:It can be moved to the bottom of the page. Search Google for "HttpModule ViewState" and you will find several.
Our AbleCommercePage base class includes such this code but it is deactivated. It causes problems as discussed above.

I have to believe that major search engines are aware of the problem and would (at some point) factor this into their ranking logic.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

Post Reply