{"id":121,"date":"2009-02-24T20:41:00","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"http:\/\/www.yazilimmutfagi.com\/?p=121"},"modified":"2009-02-24T20:41:00","modified_gmt":"1970-01-01T00:00:00","slug":"asp-net-viewstate-icerigini-sikistirmak","status":"publish","type":"post","link":"https:\/\/www.yazilimmutfagi.com\/index.php\/2009\/02\/24\/asp-net-viewstate-icerigini-sikistirmak\/","title":{"rendered":"ASP.NET ViewState I\u00e7erigini Sikistirmak"},"content":{"rendered":"<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">ViewState verileri sayfa i&ccedil;erisinde Hidden fieldlerde tutmamiza olanak saglayan bir yapidir. ViewState i&ccedil;erisinde tutulan bilgiler sunucudan istemciye g&ouml;nderilir ve ayni yolla yeniden sunucuya y&uuml;klenir. ViewStateler i&ccedil;erisindeki veriler Sessionlardan farkli olarak sunucuda saklanmazlar.<span style=\"\">&nbsp; <\/span>Her seferinde istemciye g&ouml;nderilerek ag trafigini arttirdiklari gibi sayfa boyutlarini da b&uuml;y&uuml;t&uuml;rler. ViewState i&ccedil;erisindeki bilgiler g&uuml;venlik sebebi ile sifrelenerek saklanir. Bir web sayfasi a&ccedil;ip, sayfayi sag tikladiktan sonra kaynagi g&ouml;r&uuml;nt&uuml;ler derseniz sayfa i&ccedil;erisinde bulunan sifrelenmis ViewState verisini g&ouml;rebilirsiniz.<\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><a href='www.yazilimmutfagi.com'>.<\/a><\/p>\n<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">ViewState hakkinda daha fazla bilgi i&ccedil;in daha &ouml;nce yayinladigim <span style=\"\"><a href=\"..\/MakaleOku.aspx?Makale=State+Management+ve+View+State&amp;MakaleKey=4fb0270d-37fd-4403-8871-82efe39889ce\">State Management ve View State<\/a> isimli makaleye g&ouml;z atmanizi tavsiye ederim.<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">Sayfa i&ccedil;erisindeki ViewState asagidaki gibidir.<\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 7pt;\">&lt;input type=&quot;hidden&quot; name=&quot;__VIEWSTATE&quot; id=&quot;__VIEWSTATE&quot; value=&quot;hW0f8wh7e+CFHZeGS3F2wM\/sLI0kd\/u\/LN9HyCbtEcqlTf1hpGuxs8Ii8WY5fHtv4AGWCqnLbfHC\/J8q<br \/>\n0W592ll2+N+uGJTB4+\/9eNBWBnJfaPJeUY1LgexBQ3jrWHYaMN\/29VLnTExTCksHUzuKd57kVM4Cf3aajR4<br \/>\nCldwfkTCuUXiJufnsCq0YRFsn\/R8t2Bb2fj\/WDL6vXhFL7oXIgZgVDQ5btz\/RmW9xVQo52enK0RfgKzB55EDnL<br \/>\n+JbDH725M4zBikQIbd00IgUdmCsaECn+xlD1s683NWYoAyx1hqkrR0445onKJf4YlmTtTXF5mINvdOleSxyy<br \/>\nEIR8IJf6hKY53oDfxMBlXDpof24FhmZPMazcKU8AsK4ZV8N6rVH3Uez+FAd+qZDdM9dMtRx7fliGigYHwjYV6<br \/>\nwGVlp6pC0PdIKe9o6W87FEoFumA317hBB3Ym50FbqmpKMUzFa2FVM1mWkB1oIfovB\/r\/k+VTvym8249B6<br \/>\n7dxJNFW8pPcyFzVXKVXWYQDHFDa6mXuAHE+69zkIpYIUmAKZFaQJuIhLbA0S0CssdxCGk4MKCCZzDZFU<br \/>\nsOroc5lMG\/e6RDFFuRUMRL977NVnE90B6lnVSauQIRFb7ZWfnOu\/xwjkWe7dkJMF7lyH26ljCyIeUrhel9J7rt+i<br \/>\nyCrUP062Olz+XScXfdsuM3QbMIjCeFSbv6UlbUgZJrhUvMVAezS2lmD2BvYbZTYFdUB8vw5Oc0axFK3Q2kH<br \/>\nGSYUTILiwKOSSGC1NkIwAcnUo94EdgFuMFPUYhHawD6XGIlR5iCznarmhU3UbjtUcaMm9S3HRiRrWFixjEBd<br \/>\n1zwwqcaDBIr24Lfe5eOuNvAtl9UFndgOwoYtDvp8TTfuZ4cxU961c9pcQXhwIZ424ir7BJV+P5OPq6xS\/xgCRW<br \/>\n\/pXa6fXAUvGxglxydPyByB5ou1QKKnMkfFeKxvcvOgSaCTQOW9RugNo3HV4Z5GrHcCdABr9\/71JaOtvgan142<br \/>\nuEh6r6pAbTwhf71aA8fu0DGvMAdZ2cgibxL4WhKSRWV2jiUjlkrurWMU+vxaOwTwva60PkaLPkJJvBkyN6xH0Bs<br \/>\nJW7ymEzSbdFS+yHzX3gdqj4BcZ3SlnY2zKAk9Sn9FW3JZRfCvVmoxwXgyErs4UVDEJXKdZjjQcLE5hu\/yDkOsT<br \/>\nCydkgRBEq1YkSIBKKKK3r3YzHiU7hypue+pYFCjocYPE4u9zUEsrC8SU8j1FGwLXoabxQZGvoVVe0Hu6\/qPYG<br \/>\nSbCkokGly8r2ikieyOeChKSoOGkNdBgEF2jY5YNojJBurrWQx9u6Yl9n8cxhCNjjZsnBACz7SDShai0I+APUgpU8<br \/>\n<\/span><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 7pt;\">FUcKDVipj2g8\/QvDeyYB9Od9c9SqRlBiTUuoBQG09\/eK9b8kN9OgWDiKYTxR9jDx6+VEO2SYCLprVyvT4do4t<\/span><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 7pt;\">&hellip;&hellip;<\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">Yukarida bir par&ccedil;asini g&ouml;rd&uuml;g&uuml;n&uuml;z ViewState verisi sayfa her postback oldugunda sunucuya gider. Sunucu bu veriyi &ccedil;&ouml;z&uuml;mleyerek gerekli bilgileri aldiktan sonra g&uuml;ncelleyerek yeniden sayfaya i&ccedil;erisine yerlestirir ve istemciye g&ouml;nderir. Sayfa boyutunu b&uuml;y&uuml;tmesi ve sunucu trafigini arttirmasi viewstatelerin dezavantajlarindan sayilabilir. Simdi gelelim bu dezavantaji nasil bir nebze giderebilecegimize. <\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><a href='www.yazilimmutfagi.com'>.<\/a><\/p>\n<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><strong style=\"\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">ViewState verisini Sikistirmak<\/span><\/strong><\/p>\n<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">ViewStateler &uuml;zerinde web browser herhangi bir islem yapmazlar. ViewStateler i&ccedil;erisindeki bilgileri sunucu kullanmaktadir. &Ouml;yleyse ViewState olusturulurken bu bilgiyi sikistirarak sayfaya yerlestirirsek bir nebze boyuttan kazanmis oluruz. Sunucu ViewState den okuma yapacagi zamanda sikismis veriyi yeniden a&ccedil;arak &uuml;zerinde islem yapabiliriz. Simdi gelelim bunu nasil yapabilecegimize.<\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt; text-indent: 35.4pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">Web projemize <strong style=\"\">Mengene<\/strong> adinda bir class ekleyelim ve bu classi <strong style=\"\">App_Code<\/strong> i&ccedil;erisine yerlestirelim. Mengene classi i&ccedil;erisine asagidaki kodu ekleyelim.<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt;\">public<\/span><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"> <span style=\"color: blue;\">static<\/span> <span style=\"color: blue;\">class<\/span> <span style=\"color: rgb(43, 145, 175);\">Mengene<\/span> {<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\">&nbsp;<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp; <\/span><span style=\"color: blue;\">public<\/span> <span style=\"color: blue;\">static<\/span> <span style=\"color: blue;\">byte<\/span>[] Compress(<span style=\"color: blue;\">byte<\/span>[] veri)<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp; <\/span>{<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: rgb(43, 145, 175);\">MemoryStream<\/span> output = <span style=\"color: blue;\">new<\/span> <span style=\"color: rgb(43, 145, 175);\">MemoryStream<\/span>();<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: rgb(43, 145, 175);\">GZipStream<\/span> gzip = <span style=\"color: blue;\">new<\/span> <span style=\"color: rgb(43, 145, 175);\">GZipStream<\/span>(output,<span style=\"color: rgb(43, 145, 175);\">CompressionMode<\/span>.Compress, <span style=\"color: blue;\">true<\/span>);<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>gzip.Write(veri, 0, veri.Length);<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>gzip.Close();<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue;\">return<\/span> output.ToArray();<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp; <\/span>}<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\">&nbsp;<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp; <\/span><span style=\"color: blue;\">public<\/span> <span style=\"color: blue;\">static<\/span> <span style=\"color: blue;\">byte<\/span>[] Decompress(<span style=\"color: blue;\">byte<\/span>[] veri) {<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: rgb(43, 145, 175);\">MemoryStream<\/span> input = <span style=\"color: blue;\">new<\/span> <span style=\"color: rgb(43, 145, 175);\">MemoryStream<\/span>();<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>input.Write(veri, 0, veri.Length);<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>input.Position = 0;<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: rgb(43, 145, 175);\">GZipStream<\/span> gzip = <span style=\"color: blue;\">new<\/span> <span style=\"color: rgb(43, 145, 175);\">GZipStream<\/span>(input,<span style=\"color: rgb(43, 145, 175);\">CompressionMode<\/span>.Decompress, <span style=\"color: blue;\">true<\/span>);<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: rgb(43, 145, 175);\">MemoryStream<\/span> output = <span style=\"color: blue;\">new<\/span> <span style=\"color: rgb(43, 145, 175);\">MemoryStream<\/span>();<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue;\">byte<\/span>[] buffer = <span style=\"color: blue;\">new<\/span> <span style=\"color: blue;\">byte<\/span>[64];<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue;\">int<\/span> read = -1;<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>read = gzip.Read(buffer, 0, buffer.Length);<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue;\">while<\/span>(read &gt; 0) {<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>output.Write(buffer, 0, read);<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>read = gzip.Read(buffer, 0, buffer.Length);<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>}<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>gzip.Close();<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: blue;\">return<\/span> output.ToArray();<\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-family: &quot;Courier New&quot;; font-size: 10pt;\"><span style=\"\">&nbsp; <\/span>}<\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: &quot;Courier New&quot;; font-size: 10pt;\">}<\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Yukaridaki kodu inceleyecek olursak Compress fonksiyonu Framework ile gelen GZip nesnesini kullanarak g&ouml;nderdigimiz veriyi sikistirir. Decompress ise ayni islemin tersini yapar. Simdi gelelim bu islemi sayfamizda nasil kullanacagimiza.<\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt;\" class=\"MsoNormal\"><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Sikistirma yapmak istedigimiz sayfaya ait kod kismina gelelim ve asagidaki kodu yazalim. Asagidaki islemi Masterpage i&ccedil;erisinde yapacak olursaniz <\/span><span style=\"line-height: 115%; font-family: &quot;Courier New&quot;; font-size: 10pt;\">SavePageStateToPersistenceMedium, LoadPageStateFromPersistenceMedium <\/span><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">metotlari i&ccedil;in hata alacaksiniz. Bu y&uuml;zden masterpage i&ccedil;erisinde degil sayfanin kendine ait kod kisminda uygulamaniz gerekiyor.<\/span><\/p>\n<p><span style=\"font-family: &quot;Courier New&quot;; color: blue; font-size: 10pt;\">\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; color: blue; font-family: &quot;Courier New&quot;;\">protected<\/span><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\"> <\/span><span style=\"color: blue;\">override<\/span><span style=\"color: rgb(0, 0, 0);\"> <\/span><span style=\"color: blue;\">void<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>SavePageStateToPersistenceMedium(<\/span><span style=\"color: blue;\">object<\/span><span style=\"color: rgb(0, 0, 0);\"> viewState)<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\">{<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: rgb(43, 145, 175);\">LosFormatter<\/span><span style=\"color: rgb(0, 0, 0);\"> _formatter = <\/span><span style=\"color: blue;\">new<\/span><span style=\"color: rgb(0, 0, 0);\"> <\/span><span style=\"color: rgb(43, 145, 175);\">LosFormatter<\/span><span style=\"color: rgb(0, 0, 0);\">();<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: rgb(43, 145, 175);\">MemoryStream<\/span><span style=\"color: rgb(0, 0, 0);\"> ms = <\/span><span style=\"color: blue;\">new<\/span><span style=\"color: rgb(0, 0, 0);\"> <\/span><span style=\"color: rgb(43, 145, 175);\">MemoryStream<\/span><span style=\"color: rgb(0, 0, 0);\">();<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>_formatter.Serialize(ms, viewState);<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: blue;\">byte<\/span><span style=\"color: rgb(0, 0, 0);\">[] viewStateArray = ms.ToArray();<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: rgb(43, 145, 175);\">ClientScriptManager<\/span><span style=\"color: rgb(0, 0, 0);\"> clientScript = Page.ClientScript;<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>clientScript.RegisterHiddenField(<\/span><span style=\"color: rgb(163, 21, 21);\">&quot;__COMPRESSEDVIEWSTATE&quot;<\/span><span style=\"color: rgb(0, 0, 0);\">,<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: rgb(43, 145, 175);\">Convert<\/span><span style=\"color: rgb(0, 0, 0);\">.ToBase64String(<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: rgb(43, 145, 175);\">Mengene<\/span><span style=\"color: rgb(0, 0, 0);\">.Compress(viewStateArray)));<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\">}<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; color: blue; font-family: &quot;Courier New&quot;;\">protected<\/span><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\"> <\/span><span style=\"color: blue;\">override<\/span><span style=\"color: rgb(0, 0, 0);\"> <\/span><span style=\"color: blue;\">object<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>LoadPageStateFromPersistenceMedium()<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\">{<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: rgb(43, 145, 175);\">LosFormatter<\/span><span style=\"color: rgb(0, 0, 0);\"> _formatter = <\/span><span style=\"color: blue;\">new<\/span><span style=\"color: rgb(0, 0, 0);\"> <\/span><span style=\"color: rgb(43, 145, 175);\">LosFormatter<\/span><span style=\"color: rgb(0, 0, 0);\">();<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: blue;\">string<\/span><span style=\"color: rgb(0, 0, 0);\"> vsString = Request.Form[<\/span><span style=\"color: rgb(163, 21, 21);\">&quot;__COMPRESSEDVIEWSTATE&quot;<\/span><span style=\"color: rgb(0, 0, 0);\">];<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: blue;\">byte<\/span><span style=\"color: rgb(0, 0, 0);\">[] bytes = <\/span><span style=\"color: rgb(43, 145, 175);\">Convert<\/span><span style=\"color: rgb(0, 0, 0);\">.FromBase64String(vsString);<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\"><span style=\"\">&nbsp;&nbsp;&nbsp; <\/span>bytes = <\/span><span style=\"color: rgb(43, 145, 175);\">Mengene<\/span><span style=\"color: rgb(0, 0, 0);\">.Decompress(bytes);<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"\"><span style=\"color: rgb(0, 0, 0);\">&nbsp;&nbsp;&nbsp; <\/span><\/span><span style=\"color: blue;\">return<\/span><span style=\"color: rgb(0, 0, 0);\"> _formatter.Deserialize(<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\"><span style=\"\">&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"\">&nbsp;&nbsp;&nbsp;<\/span><\/span><span style=\"color: rgb(43, 145, 175);\">Convert<\/span><span style=\"color: rgb(0, 0, 0);\">.ToBase64String(bytes));<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 10pt;\" class=\"MsoNormal\"><span style=\"font-size: 10pt; line-height: 115%; font-family: &quot;Courier New&quot;;\"><span style=\"color: rgb(0, 0, 0);\">}<\/span><\/span><\/p>\n<p style=\"margin: 0cm 0cm 0pt; line-height: normal;\" class=\"MsoNormal\">&nbsp;<a href='www.yazilimmutfagi.com'>.<\/a><\/p>\n<\/span><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\"><span style=\"\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>G&ouml;rd&uuml;g&uuml;n&uuml;z gibi tek yaptigimiz ASP.NET sayfalarina ait iki metotu override etmek ve i&ccedil;erisinden daha &ouml;nce yazdigimiz Mengene sinifina ait metotlari &ccedil;agirmak. Hepsi bu kadar. Simdi sayfalariniza ait boyutlara bakacak olursaniz % 10 ile % 50 arasi bir k&uuml;&ccedil;&uuml;lme fark edeceksiniz. Ben yazilim mutfagina ekledim ve ana sayfada %10&rsquo;luk bir k&uuml;&ccedil;&uuml;lme saglarken Makale okuma sayfasinda % 45&rsquo;lik bir kazan&ccedil; sagladim. Hi&ccedil; de k&uuml;&ccedil;&uuml;msenecek bir kazan&ccedil; degil. Helede hosting firmalarina daha fazla trafik i&ccedil;in fazladan para &ouml;demek istemiyorsaniz. Peki yaptigimiz bu islemin maliyeti ne? Verileri sikistirmak sayfa boyutunu k&uuml;&ccedil;&uuml;lt&uuml; dolayisiyla ag trafigimizde o nebze azalmis oldu. Bu sikistirma islemi sirasinda sunucumuzun islemcisine biraz is d&uuml;s&uuml;yor. E bunu da artik hosting firmamiz d&uuml;s&uuml;ns&uuml;n <\/span><span style=\"line-height: 115%; font-family: Wingdings; color: rgb(58, 58, 58); font-size: 10pt;\"><span style=\"\">J<\/span><\/span><span style=\"line-height: 115%; font-family: Verdana; color: rgb(58, 58, 58); font-size: 10pt;\">. <\/span><\/p>","protected":false},"excerpt":{"rendered":"<p>Bu makalemizde ViewState i&#231;erigini sikistirarak sayfa boyutlarimizi nasil k&#252;&#231;&#252;ltecegimiz ve ag trafigini nasil azaltacagimizi konusacagiz.<\/p>\n","protected":false},"author":517,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[407],"tags":[5201,5660,6035,5762,4315,4459,6236,5067],"_links":{"self":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts\/121"}],"collection":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/users\/517"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/comments?post=121"}],"version-history":[{"count":0,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts\/121\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/media?parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/categories?post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/tags?post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}