I've just completed Chapter 5 of the MCTS Self Paced Training Kit for 70-515 (Web Developer).
Over the past month or two I've been slowly working my way through the book, and the things that I read are in some cases, quite amazing.
Its the little things I'm being educated about. Take for instance two of the most (at least I believe they are) misunderstood methods in regards to site navigation. Response.Redirect and Server.Transfer. Although these two methods appear to do the same thing, when I read the actual technical differences between the two, my jaw dropped.
For instance, Response.Redirect is called a Client Side Browser Redirect, meaning that after a postback, the application redirects to another page as if a user has clicked a hyperlink (or some other non-server related object), meaning no data is preserved between the post from one page to another. This is by no means a Bad Thing, however when I read the correct usage of Server.Transfer (which is called a Server Side Transfer), I had a fluttery feeling of butterflies in my stomach. Server.Transfer preserves the previous page's data in a property called (you guessed it!) PreviousPage, whereas if a page is loaded via Response.Redirect, the PreviousPage property is never populated.
Oh the possibilities!
With Response.Redirect, the most widely used method of preserving data across page transfers is passing key/value pairs in the QueryString. In most cases nothing is wrong with this, the only drawback is that you can potentially display sensitive data to the user (as the QueryString appears as part of the Url of the page you are redirecting to, in plain text). Server.Transfer however, doesn't show (to the user) that they have left the original page! In addition to this, if you've set up your page properties correctly you can access whatever you need to in the new page via the magical PreviousPage property.
Ive used both of these methods frequently, without quite knowing how it worked, only that it did. Upon reading this chapter, I am viewing site navigation in a whole new (and more accurate!) light. From now on, when doing dev work in any web application, I will now analyze which method would be better and apply this wonderful tidbit accordingly.
Comments