ScriptManager's EnablePartialRendering and SupportsPartialRendering properties

In ASP.NET AJAX's ScriptManager control there are two properties that seem quite similar, but are in fact very different:

namespace System.Web.UI {
public class ScriptManager : Control {
public bool EnablePartialRendering { get; set; }
public bool SupportsPartialRendering { get; set; }
...
}
}

The primary difference between these two properties is who the audience is for each. EnablePartialRendering is intended for the page developer. That is, the person who is building the ASP.NET page and placing the ScriptManager on it. They get to decide whether they're interested at all in using the partial rendering feature. For example, for optimization purposes they might disable the partial rendering feature entirely to prevent any extra script from being downloaded. Or perhaps to debug an issue they want to temporarily disable UpdatePanels from doing async postbacks.

On the other hand, SupportsPartialRendering is mostly for component developers and sometimes for page developers. It's used in two ways, depending on the scenarios. The most common way is for control developers to check its value to see whether the current request is using partial rendering. The value is a combination of whether the page developer wants to use partial rendering (EnablePartialRendering) at all along with whether the current request supports partial rendering. To determine whether the request supports partial rendering the ScriptManager looks at the request's browser capabilities.

The other way that SupportsPartialRendering is used is for page developers who want to override the ScriptManager's default browser detection logic. When we release ASP.NET AJAX 1.0 we came up with a set of checks that worked great for the browsers we knew we supported at the time (IE6, IE7, Firefox, Safari, and maybe some others). Inevitably, the market of browsers has changed since then with newer browsers appearing, and our logic isn't always right. There's your chance to override it!

Another case people want to override our default browser detection is when proxies alter the browser headers. For example, I've heard from a number of customers that they are using web proxies that replace the HTTP User Agent header with the proxy's name and version. While I think that's a ridiculous thing for a proxy to do, that's how some of them do it. When ScriptManager sees "FooProxy v1.23" as the agent, it decides that it's not a known browser and won't let you use partial rendering. The customer's workaround was to set SupportsPartialRendering to true when EnablePartialRendering was true and the user agent was the FooProxy.

No Comments