开发者

Problems using Firebug to view script on an ASP.NET page with a very large VIEWSTATE

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 开发者_JAVA百科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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜