문제

나는 내 사이트의 성능을 향상 시키려고 노력하고 있습니다. ASP.NET 사이트에 대한 일반적인 제안은 가능한 한 ViewState를 제거하는 것입니다. 나는 이것이 페이지의 각 컨트롤을 별도로 또는 전체 페이지에 대해 수행 할 수 있다고 생각합니다.

내 질문은 Page ViewState를 비활성화하는 경우 Mas

도움이 되었습니까?

해결책

Yes, the page is the originator of the page flow. Thus, disabling viewstate for the page takes the viewstate rendering out of the OnInit process. A better question would be why does disabling the viewstate for the master page do the same?

다른 팁

There's an easy way to shrink all your viewstate.

Step 1. Create a new class that looks like this:

Imports System  
Imports System.Web.UI

Public Class SessionPageStateAdapter
    Inherits System.Web.UI.Adapters.PageAdapter

    Public Overrides Function GetStatePersister() As System.Web.UI.PageStatePersister

        Return New SessionPageStatePersister(Page)

    End Function
End Class

Step 2. Add an App_Browsers folder to your project.

Step 3. In your new App_Browsers folder, add a new default.browser file that looks like this.
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.Page" adapterType="[YourNamespaceGoesHere].SessionPageStateAdapter" />
</controlAdapters>
</browser>
</browsers>

When you run your pages now, you should find your viewstate size has dropped to a few bytes. The SessionPageStateAdapter class intercepts viewstate before it gets served to the browser and holds it in on the server in Session state. The bit of viewstate that still gets sent to the client is just an identifier that is used to reconstitute the original viewstate when the page gets posted back to the server.

You might find this article helpful:
http://msdn.microsoft.com/en-us/library/ms972976.aspx

Just a quick note on the side before optimising the site, have you optimised the server by making sure all the files are gzipped before being sent.

If not this will get you a nice boost before you even start tinkering with the page.

http://www.codinghorror.com/blog/archives/000059.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top