1 / 28


Asp.net. Page tracing, state management. Using View state. View state. One of the most common way to store information Can be used to web controls, simple data types and custom objects. The viewstate collection. ViewState property. Making view state secure.

Télécharger la présentation


An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

  1. Asp.net Page tracing, state management

  2. Using View state

  3. View state • One of the most common way to store information • Can be used to web controls, simple data types and custom objects

  4. The viewstate collection • ViewState property

  5. Making view state secure • The view-state information is simply patched together in memory and converted to a Base64 string. • Tamper-Proof View State • Hash code is a cryptographically strong checksum.

  6. Private view state • If information is secret, enable view-state encryption. • Or use the web.config • Always • Never • Auto - Page.RegisterRequiresViewStateEncryption() should be used to encrypt

  7. Retaining member variables

  8. Storing custom objects • Use serialization to convert it to stream of bytes to be added to the hidden input field page.

  9. Storing // Store a customer in view state. Customer cust = new Customer("Marsala", "Simons"); ViewState["CurrentCustomer"] = cust; • Retrieving // Retrieve a customer from view state. Customer cust; cust= (Customer)ViewState["CurrentCustomer"];

  10. Transferring information between pages

  11. Cross-page posting • A cross-page postback is a technique that extends the postback mechanism you’ve already learned about so that one page can send the user to another page, complete with all the information for that page.

  12. http://www.youtube.com/watch?v=snBg0esufOI

  13. The query string • Passing information by using a query string in the URL http://www.google.com/search?q=organic+gardening • Sending Response.Redirect(“newpage.aspx?recordID=10”); • Receiving String ID= Request.QuertyString[‘recordID’];

  14. url encoding • Allowed characters – alphanumeric and $-_.+!*’(), • Some browsers are tolerant than others • & and # are have special meanings • Encode to replace special characters - &  %26

  15. Using cookies

  16. Small files that are created in the web browser’s memory (if they’re temporary) or on the client’s hard drive (if they’re permanent). • One advantage of cookies is that they work transparently, without the user being aware that information needs to be stored. • They also can be easily used by any page in your application and even be retained between visits, which allows for truly long-term storage. • They suffer from some of the same drawbacks that affect query strings—namely, they’re limited to simple string information, and they’re easily accessible and readable if the user finds and opens the corresponding file.

  17. Some users disable cookies on their browsers, which will cause problems for web applications that require them. • Also, users might manually delete the cookie files stored on their hard drives. But for the most part, cookies are widely adopted and used extensively on many websites. • Use System.Net

  18. Managing session state • Allows data storage in the memory • Protected and not transmitted to the client • Every client has a different session and distinct collection of information

  19. Session tracking • Using cookies • Using modified URLS

  20. Using session state

  21. Session state can be lost in several ways • If the user closes and restarts the browser • If the user accesses the same page through a different browser windows • If the session times out due to inactivity • If your web page code ends the session by calling the Session.Abandon() method

More Related