I was going through Scott's list of .NET questions at http://www.hanselman.com/blog/WhatGreatNETDevelo开发者_如何学编程persOughtToKnowMoreNETInterviewQuestions.aspx
In a comment there is a scenario - You are reviewing an ASP.NET application and find that the viewstate is storing "id", which is being used for different unrelated purposes on different pages. Perhaps for PersonID in one page, productID on other page etc.
What will your recommendation be?
I don't see a problem wih this. Each page, and therefore each ViewState instance, has a different context. There is no connection of the ViewState items in one page to the ViewState items in another page, so there is no chance of confusing them. The nature of the 'id' should be obvious when coding the page - it is a person id, a product id, a customer id, or whatever.
精彩评论