September 2005 - Posts

[Solid Quality ASP.NET] Bits and pieces of your viewstate
28 September 05 04:39 PM | despos | 6 comment(s)

Everybody complains about the size of the viewstate. And with good reason. I'm certainly not here to say that there's a genial trick to vaporize the viewstate that nobody knows on the face of the earth. However, one of the problems you may experience out of a too-large viewstate is that it is too large to fit into the request. Sometimes the underlying browser is not capable of carrying all those bytes back and forth. As a result, the contents of the view state is truncated and the application fails. This is particularly likely to happen on pretty simple Web browsers such as WebTV and PDAs. In addition to remove the viewstate altogether, is there other you can try?

In ASP.NET 1.x, you could create a custom page class, override the LoadPageStateFromPersistenceMedium and SavePageStateToPersistenceMedium methods and make them read and write viewstate contents in the session state, in a database, or in any other data store on the server. Neither a mission-impossible task, nor an easy one. The devil is in the details. You must be absolutely sure that a particular page retrieves its own viewstate. Not all solutions are good at this.

So what's new in ASP.NET 2.0? There's a new attribute in the <pages> section named maxPageStateFieldLength

<pages maxPageStateFieldLength="5" />

It indicates the maximum size allowed for the viewstate. If the real size exceeds the value set in the web.config file the viewstate is sent in chunks. Here's how:

input type="hidden" name="__VIEWSTATEFIELDCOUNT" id="__VIEWSTATEFIELDCOUNT" value="16" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPD" />
<input type="hidden" name="__VIEWSTATE1" id="__VIEWSTATE1" value="wUKLT" />
<input type="hidden" name="__VIEWSTATE2" id="__VIEWSTATE2" value="I2MjI" />
<input type="hidden" name="__VIEWSTATE3" id="__VIEWSTATE3" value="3NDkw" />
<input type="hidden" name="__VIEWSTATE4" id="__VIEWSTATE4" value="NA9kF" />
<input type="hidden" name="__VIEWSTATE5" id="__VIEWSTATE5" value="gICAw" />
<input type="hidden" name="__VIEWSTATE6" id="__VIEWSTATE6" value="9kFgI" />
<input type="hidden" name="__VIEWSTATE7" id="__VIEWSTATE7" value="CCg88" />
<input type="hidden" name="__VIEWSTATE8" id="__VIEWSTATE8" value="KwANA" />
<input type="hidden" name="__VIEWSTATE9" id="__VIEWSTATE9" value="GRk7N" />
<input type="hidden" name="__VIEWSTATE10" id="__VIEWSTATE10" value="FNJbP" />
<input type="hidden" name="__VIEWSTATE11" id="__VIEWSTATE11" value="PZl6t" />
<input type="hidden" name="__VIEWSTATE12" id="__VIEWSTATE12" value="C+gkP" />
<input type="hidden" name="__VIEWSTATE13" id="__VIEWSTATE13" value="/XMyn" />
<input type="hidden" name="__VIEWSTATE14" id="__VIEWSTATE14" value="MRGPs" />
<input type="hidden" name="__VIEWSTATE15" id="__VIEWSTATE15" value="=" />

By default, the attribute is set to -1 which means that no maximum size is defined. Therefore, things work like in ASP.NET 1.x by default. The final byte count of the page is even a bit higher so THIS IS NOT a way to optimize the download time. It is a simple, effective, and inexpensive way of sending large viewstates over limited channels.

 

Solid Quality Windows Workflow
20 September 05 01:16 PM | despos | 1 comment(s)

In the past months, I had the great chance to take a look at some early builds of Windows Workflow Foundation (WWF). No matter the less-than-beta quality of some code and the difficulty of installing it, it was clear since the beginning that it was going to be great stuff.

Today, with the Beta 1 available for download you can start playing yourself with the framework. There's an "excellent" (ehm...) walkthrough article available here for you to form a clear idea of what it is.

Of all the wonders presented at PDC, I'm fairly sure that WWF is one of the hottest, and -- let me say that -- one of the most real... (Any subliminal reference to Linq is ... deliberate. More on this soon)

Solid Quality ASP.NET
20 September 05 01:08 PM | despos | 3 comment(s)

After a few years of pleasant work at Wintellect, today I officially join another great company--Solid Quality Learning.

Among other things, this means that any email sent to either dinoe or dinoes - at - wintellect.com will never reach me. For future contacts, you can use this blog or email dino, at Solid Quality Learning, dot com.

 

 

 

Open for suggestions
01 September 05 05:43 PM | despos | 18 comment(s)

As mentioned in a previous post, the ASP.NET 2.0 Core Reference book is done, and I just started on the second book--Advanced Topics.

Effectively, the Microsoft Press Web site is not particularly clear on this point, so let me clarify (and sorry for any repetition you might find)

I'll have two books out on ASP.NET 2.0

Even though the Core Reference book is already on sale on Amazon (and apparently is performing almost as high as the book on ASP.NET 1.x), neither Amazon nor the MS Press Web site to date offer enough information on what will really be in. Refer to this post for the TOC of the two books. 

This said, feel free to suggest examples and topics I can cover in the advanced book. Can't wait to hear your thoughts. 

 

ASP.NET: State Server Gems
01 September 05 01:06 PM | despos | 2 comment(s)

The September 2005 issue of MSDN Magazine contains an excellent article from one of program managers on the Web Platform and Tools Team at Microsoft--Michael Volodarsky. The article examines and suggests best practices to design and deploy high-performance and secure session solutions. If you're doing any serious ASP.NET development (and not just with coming-very-soon 2.0 version) that article is a must-read.

In particular, I'd like to emphasize a passage from the text regarding the ASP.NET state-server--the external process (aspnet_state.exe) that, started as a Windows service, serves as a session state out-of-process data store. In regard to this component, it is important to note that it doesn’t oppose any authentication barrier to requestors. In other words, it means that anyone who can get access to the network (and place calls to the server) is potentially free to access session data for all sessions. To protect session state and make sure that it is only accessed by the Web server machine, you can use a firewall or IPSec policies. Another security related countermeasure consists in changing the default port number (42424 by default). However, simply changing this number in the web.config file (precisely in the TCP connection string) is not enough. In ASP.NET 2.0, as well as in ASP.NET 1.x, you also need to edit a registry key. Locate the following:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters

and write the port number in the REG_DWORD Port entry.

Another handy suggestion from the Michael's article regards remote connections to the state server process. By default, the state server only listens to local loopback interface for connections. If the state server is on another machine than the Web server, you must enable remote connection explicitly. Once again, this requires another registry change. Under the aforementioned key, set the REG_DWORD AllowRemoteConnection entry to a nonzero value.

"Programming Microsoft ASP.NET 2.0" Coming Soon
01 September 05 12:46 PM | despos | 17 comment(s)

ASP.NET is the culmination of Web development technologies that rapidly followed one after the other over the past ten years—the new version building and improving upon its predessesor. As a result, ASP.NET is currently the most technologically advanced, feature-rich, and powerful platform for building distributed applications transported by the HTTP protocol.

I’m pleased to announce that I’ve just completed Programming Microsoft ASP.NET 2.0, a book specifically about this state-of-the-art Web programming with Microsoft .NET technologies. I’ve reviewed the 15 chapters of the first ASP.NET book—the Core Reference, which will hit the bookstore shelves this November, just in time for Microsoft’s release of the .NET 2.0 platform.

 

Programming Microsoft ASP.NET 2.0 is divided into to books.. The Core Reference covers the core technology and the Advanced carries on covering advanced ASP.NET 2.0 topics. The Advanced book is expected to hit the book store shelves in January, 2006. Of course, I’ll post content from the Advanced book over the next few months.

 

The Core Reference book is 800 pages and covers the fundamentals of ASP.NET—what is essential for developers to know in order to build and deploy Web applications. You’ll find it useful whatever version of ASP.NET you use, with each topic covered in a sort of top-down approach—starting with the broader description of the feature and then drilling down to the implementation and programming details of the particular ASP.NET version.

 

In this book you won’t find specific 2.0 features implemented for 1.x. Instead, you’ll find the feature discussed in a version-agnostic way, and then detailed for ASP.NET 2.0 with relevant changes from 1.x highlighted. This book is for today’s ASP.NET developers. 

 

What’s in the Core Reference book? Take a look at the Table of Contents.

 

Chapter

Title

1

The ASP.NET Programming Model

2

Web Development in Visual Studio .NET

3

Anatomy of an ASP.NET Page

4

ASP.NET Core Server Controls

5

Working with the Page

6

Rich Page Composition

7

ADO.NET Data Providers

8

ADO.NET Data Containers

9

The Data Binding Model

10

Creating Bindable Grids of Data

11

Managing Views of a Record

12

The HTTP Request Context

13

ASP.NET State Management

14

ASP.NET Caching

15

ASP.NET Security

 

What’s not in this book? There’s no coverage for iterative controls (Repeater/DataList), user controls, custom controls, HTTP handlers and modules, scripting (AJAX.NET, callbacks), compilation model, runtime internals, Web Parts, mobile development, site navigation, custom providers, hierarchical data and controls, Web services, imaging, configuration. Here’s the to-date TOC for the Advanced Topics book.

 

Chapter

Title

1

The ASP.NET Compilation Model

2

HTTP handlers and modules

3

ASP.NET Configuration

4

Building ASP.NET Providers

5

Building a Rich Environment for Pages

6

Working with Script Code

7

Composing Pages with Web parts

8

Programming for the mobility

9

Working with Images

10

Working with Web services

11

Site Navigation

12

ASP.NET Iterative controls

13

Web Forms User Controls

14

Creating Custom ASP.NET Controls

15

Data-bound and Templated Controls

16

Design-time Support for Custom Controls

 

Topics that I’ll certainly cover in the Advanced Topics book include custom $-expressions, build providers, asynchronous pages, menu/treeview, custom providers.  

More Posts