views:

114

answers:

2

I inherited an ASP.NET application that builds pages with massive viewstate values. As I have been working through it, I assumed I would be able to use Firebug to inspect the output and set breakpoints in the resulting client-side script.

What I have found instead is that whenever Firebug encounters a large viewstate, it completely chokes on rendering the Script tab, making it almost impossible to set and use breakpoints.

What I see in the output is something very similar to this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD> --snipped-- </HEAD>
<body>
    <form name="..." method="post" action="..." id="...">
    <input 
       type="hidden" 
       name="__VIEWSTATE" 
       id="__VIEWSTATE"
       value="/V4dAUdVmVyc2lvbiAzLjAsIGJ1aWxkIDMxIChlbi1VUylkAgUPFgIfAGVkAgsPDxYCHwAFC1RpbSBCb29ybWFuZGQCDw8QDxYCHgtfIURhdGFC
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD> --snipped-- </HEAD>
<body>
    <form name="..." method="post" action="..." id="...">
    <input 
       type="hidden" 
       name="__VIEWSTATE" 
       id="__VIEWSTATE"
       value="/V4dAUdVmVyc2lvbiAzLjAsIGJ1aWxkIDMxIChlbi1VUylkAgUPFgIfAGVkAgsPDxYCHwAFC1RpbSBCb29ybWFuZGQCDw8QDxYCHgtfIURhdGFC
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD> --snipped-- </HEAD>
<body>
    <form name="..." method="post" action="..." id="...">
    <input 
       type="hidden" 
       name="__VIEWSTATE" 
       id="__VIEWSTATE"
       value="/V4dAUdVmVyc2lvbiAzLjAsIGJ1aWxkIDMxIChlbi1VUylkAgUPFgIfAGVkAgsPDxYCHwAFC1RpbSBCb29ybWFuZGQCDw8QDxYCHgtfIURhdGFC

In other words, Firebug gets halfway through the viewstate value, then starts over from the top, rendering everything from the DOCTYPE declaration to the same spot in the viewstate.

While I recognize (and am working on) the fact that there is a problem with the way this application uses viewstate, I am surprised by Firebug's handling of the output. I have the latest versions of both Firefox and Firebug. Is there a setting I can change to make the script tab render correctly? Has anyone else had issues with Firebug and ASP.NET viewstate?

A: 

Have you tried any other JavaScript debugging tools?

I know Chrome and Safari have script debuggers built in or there is Venkman, the FireFox plug-in.

Keith Bloom
Since I was asking about Firebug, some people might say that a response of "use a different tool" isn't a useful response. However, I think it's an important part of troubleshooting, and in this case, it led to a very interesting result: the viewstate problem does not occur in the Venkman debugger!Also, thanks for introducing me to a new tool. It won't cover everything I use Firebug for, but it seems to be very good at the task it was designed for.
Boris Nikolaevich
A: 

While it doesn't address the underlying ViewState problem, I have implemented the following workaround in the specific page where I need to use Firebug. Note that I am not recommending SessionPageStatePersister as the ultimate solution (storing this huge viewstate on the server only moves the problem) but I thought I'd share the workaround that allowed me to move forward.

#if DEBUG
    // When debugging, it is useful to not have the large viewstate values 
    // output to the browser.
    protected override System.Web.UI.PageStatePersister PageStatePersister
    {
        get
        {
            return new SessionPageStatePersister(this);
        }
    }
#endif

This ensures that only the output I care about goes to the browser when I am debugging, but also doesn't change the current production viewstate behavior.

Boris Nikolaevich