Click here to Skip to main content
15,892,517 members
Articles / Web Development / ASP.NET

Keep ASP.NET ViewState out of ASPX Page for Performance Improvement

Rate me:
Please Sign up or sign in to vote.
4.37/5 (46 votes)
23 Jul 2005GPL34 min read 309.3K   1.1K   108  
How you could improve performance of your ASP.NET projects, keeping ViewState on the server instead of on the ASPX page.
<VisualStudioProject>
    <VisualBasic
        ProjectType = "Web"
        ProductVersion = "7.10.3077"
        SchemaVersion = "2.0"
        ProjectGuid = "{7B3F00FA-EF4D-42C8-9157-4ACE6016445F}"
    >
        <Build>
            <Settings
                ApplicationIcon = ""
                AssemblyKeyContainerName = ""
                AssemblyName = "ServerViewState"
                AssemblyOriginatorKeyFile = ""
                AssemblyOriginatorKeyMode = "None"
                DefaultClientScript = "JScript"
                DefaultHTMLPageLayout = "Grid"
                DefaultTargetSchema = "IE50"
                DelaySign = "false"
                OutputType = "Library"
                OptionCompare = "Binary"
                OptionExplicit = "On"
                OptionStrict = "Off"
                RootNamespace = "ServerViewState"
                StartupObject = ""
            >
                <Config
                    Name = "Debug"
                    BaseAddress = "285212672"
                    ConfigurationOverrideFile = ""
                    DefineConstants = ""
                    DefineDebug = "true"
                    DefineTrace = "true"
                    DebugSymbols = "true"
                    IncrementalBuild = "true"
                    Optimize = "false"
                    OutputPath = "bin\"
                    RegisterForComInterop = "false"
                    RemoveIntegerChecks = "false"
                    TreatWarningsAsErrors = "false"
                    WarningLevel = "1"
                />
                <Config
                    Name = "Release"
                    BaseAddress = "285212672"
                    ConfigurationOverrideFile = ""
                    DefineConstants = ""
                    DefineDebug = "false"
                    DefineTrace = "true"
                    DebugSymbols = "false"
                    IncrementalBuild = "false"
                    Optimize = "true"
                    OutputPath = "bin\"
                    RegisterForComInterop = "false"
                    RemoveIntegerChecks = "false"
                    TreatWarningsAsErrors = "false"
                    WarningLevel = "1"
                />
            </Settings>
            <References>
                <Reference
                    Name = "System"
                    AssemblyName = "System"
                />
                <Reference
                    Name = "System.Data"
                    AssemblyName = "System.Data"
                />
                <Reference
                    Name = "System.Drawing"
                    AssemblyName = "System.Drawing"
                />
                <Reference
                    Name = "System.Web"
                    AssemblyName = "System.Web"
                />
                <Reference
                    Name = "System.XML"
                    AssemblyName = "System.Xml"
                />
            </References>
            <Imports>
                <Import Namespace = "Microsoft.VisualBasic" />
                <Import Namespace = "System" />
                <Import Namespace = "System.Collections" />
                <Import Namespace = "System.Configuration" />
                <Import Namespace = "System.Data" />
                <Import Namespace = "System.Drawing" />
                <Import Namespace = "System.Web" />
                <Import Namespace = "System.Web.UI" />
                <Import Namespace = "System.Web.UI.HtmlControls" />
                <Import Namespace = "System.Web.UI.WebControls" />
            </Imports>
        </Build>
        <Files>
            <Include>
                <File
                    RelPath = "AssemblyInfo.vb"
                    SubType = "Code"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Global.asax"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Global.asax.vb"
                    DependentUpon = "Global.asax"
                    SubType = "Code"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Global.asax.resx"
                    DependentUpon = "Global.asax.vb"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Styles.css"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "VSPage.vb"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Web.config"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "WebForm1.aspx"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "WebForm1.aspx.vb"
                    DependentUpon = "WebForm1.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "WebForm1.aspx.resx"
                    DependentUpon = "WebForm1.aspx.vb"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "WebForm2.aspx"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "WebForm2.aspx.vb"
                    DependentUpon = "WebForm2.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "WebForm2.aspx.resx"
                    DependentUpon = "WebForm2.aspx.vb"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Generated SourceCode Examples\WebForm1 - Generate SourceCode Example.txt"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Generated SourceCode Examples\WebForm2 - Generate SourceCode Example.txt"
                    BuildAction = "Content"
                />
            </Include>
        </Files>
    </VisualBasic>
</VisualStudioProject>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Web Developer
Brazil Brazil
Régis Daniel is currently living in Itaúna, MG, Brazil. He works with programming since 1999 and actualy works as IT Manager on a wholesaler company. He has experiency as Oracle DBA, and also worked as a PalmOS developer using CodeWarrior with C/C++.
Now a days he works on .NET Framework, developing solutions on Visual Basic.NET and ASP.NET. During his spare time, he likes reading books, watching movies and pratices some outdoor activities, like Trekking and Camping.

Comments and Discussions