I'll be starting a complete re-write of a system in the coming weeks. I'll be using ASP.NET MVC 2.I'm still trying to determine what I should be using as far as TDD, mocking, and IOC is concerned. I was thinking:
VSTEST for writing my TDD tests (or possibly nUnit) Moq as my mocking framework (for creating doubles and fakes) Moq for IOC development Not sure exactly what the ideal setup should be and I'm continuing to research what's available. I'd like some feedback from the community on the most optimal toolsets for TDD, mocking, and IOC.
What is the best method to cache the following? I am creating an intranet web application template that will display the message, e.g., Good Morning, Justin Satyr! near the top of my master page header. Obviously, I will have to determine whether to show Morning, Afternoon or Evening. For clarity, my code is below:
I do not want to re-determine this on each page load because that seems moderately redundant and because I have to poll a SQL server to retrieve the user's full name. What is the best way to cache this nformation? If I cache it for the length of the session, then if the user begins using the application at 11:00 AM and finishes at 3:00 PM, it will still say Good Morning. Is the best thing to do simply re-determine the M/A/E word each page load and cache the person's full name for the session? Or is there a better way?
i want to know if the only way to get information from database and transform them into objects is with a datareader or with a dataadapter and them looping throw the datarows, cause i have a lot of records in the table and i have to find the fastest way to do it. (like 10,000,000 records).
If that is even the right combination of controls to use.. I have a page that will display a list of files that have been processed or processing.. its not really time sensitive, but would like for the page to refresh the gridview every say every minutelonger(not determined yet)Is that the most optimal way to accomplish this, i mean if you are on the page, i dont want you to have to hit refresh to see any new records or status changes to the existing records..
I have a requirement where I would not know the columns and any result set information at design-time, so I'd be generating the data-display control dynamically.What is the most suitable way to display this type of information on-the-fly in a table/grid like structure on an ASP.NET page considering the following parameters (in order of importance):
Performance Extensibility Usability
I know I can dynamically generate a gridview/repeater/listview control but what I'd like to understand is which option (from stated ones or any other beyond these) would be an optimal solution..S. Paging and Sorting are part of desired functionalities, but can be overlooked if the solution is overwhelming. :)
I just want to know, What parameters or attributes should be taken in connection string so as to handle high traffic enterprise applications? Like in general we use server, initial catalog, userid, passwd. Some times we add timeout , and in some scenario pool etc. But i don't know what attributes should i take in as my common practice apart from above.
Now here is the weird thing. First i am running it locally on the built in vs2008 web server.I load my control in fine, do a postback from a linkbutton, locally on my machine it all works fine, no issue.However when it goes onto my host, it falls over with the message:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.Now i also load controls dynamically and use postbacks and things in the admin area of the site...and that works fine, however my front end just keeps failing? See the code behing below:
I have been getting this error a lot lately with some of my users, and I had a couple of concerns with view state and I have read so many articles but I am still lost..
1. I use masterpage on all the pages and I need viewstate for some of the pages but..
There is a page where a user will fill out the information and then submit this data to a cgi server, and it is where I get most of the Client Disconnected errors, what would happen if I disable viewstate when they click on that button?
Now when a user browses from one page to another, does the view state from the previous page get deleted? If not how would I delete it?
Does the master page have its own viewstate? Would I be able to make sure none of items on my master page are using the viewstate?
I have a shopping cart page (Cart.aspx) that has a button that will (sometimes) post to a third party payment gateway, if payment is necessary. The payment gateway will process the payment and then do a silent post to my website (Order.aspx) so I can update the order status.
Order.aspx always throws an invalid viewstate error, even though viewstate is disabled on the page.
What's happening is that Cart.aspx (which has viewstate enabled) posts to the payment gateway, and the gateway will post it back as part of the silent post. Even though Order.aspx has viewstate disabled and validation disabled, it still tries to validate the __viewstate field it's being given.
I know setting EnableViewState=false will disable the rendering of the __viewstate field, but if another page provides the field, shouldn't it still skip validation? I tried calling ViewState.Clear() on the Page_Init event of Order.aspx, but ViewState is apparently empty. how to get around this? I don't want to disable ViewState on Cart.aspx (in some cases it may be necessary), but I can't figure out how to clear it on Order.aspx.
ViewState["datalist"] = dtlstForm; and retrieved it as: DataList lis = (DataList)ViewState["datalist"]; then folowing error comes: Type 'System.Web.UI.WebControls.DataList' in Assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
Upon page reloads I want to retain the values the user had typed in upon hitting submit. I worry about viewstates being cumbersome for pages, both in bandwidth and in time for a page viewer to download the page. I am cheap with my bytes :p
My question is instead of using server controls and such I am having the form on the page do a get to itself and on the aspx putting <input type="text" id="user_email" name="email" value="<%=Request.Form["email"] %>" /> This allows me to not use viewstate. Are there any potential shortcomings to doing things this way? My goal is always for a lighter page and efficiency even if it is more work.
i want to set the property of that enum in my view state in such a way that whenever view state is null return Watch else EmailPreference.how can i get and set the property?
i am new at the ViewState and i am looking to see what values are stored within it. I know how to loop through an array to check for a value but i do not know how to go about doing that for a ViewState("test") property.Let's say i have added "bob, tom, Jim" to a ViewState called ViewState("test"). I would like to be able to see if "tom" was in the ViewState("test"). If not then add it but if it exists already then skip it.
Public strIDArray() As String Public vsSaver As String Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If EnableViewStateMAC is set to true, ASP.NET will generate a hashcode for the ViewState data and compare it to the hashcode stored in the posted value. What prevents an attacker from setting the hash based on the altered form values?
well what i want to find out is how can i figure out if some change occurd in page when postback , i mean when the first state of the page hahe any changes after postback . I thought maybe somehow to compare viewstaes but i can not find out how can i do that.
lately I'm using less and less the ASP.NET controls and also turns off the viewstate in almost any page, in my opinion its easier to maintain your pages, you get more control over what happening and most importantly it gives a serious performance boost to large pages (no view state). I'm also using a lot of ajax in my projects (without the script manager / updatecontrol but via javascript) is anyone here working like this? is this bad practice ?
The following message appears in our log:The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request. alot has been written about this subject. However, I cannot reproduce this behavior, and I only find a couple thousand errors per day in the logs; so it's probably isn't that obvious.
The page in question has an UpdatePanel and loads one of three usercontrols depending on the querystring.Is there any known issue with some clients, or any other possible explanation?
In building custom controls, I've seen two patterns for using the viewstate. One is to use properties to disguise the viewstate access as persistent data.
public bool AllowStuff { get { return (ViewState[constKeyAllowStuff] != null) ? (bool)ViewState[constKeyAllowStuff] : false; } set { ViewState[constKeyAllowStuff] = value; } }
The other is to use private member fields and to override the Load/SaveViewState methods on the control and handle it all explicitly:
(I cut out a lot of safety checking for clarity, so just ignore that.) Is there are particular advantage to one method over the other? I can't see how they'd differ much performance wise. Version 1 is lazy, so I guess you save a bit if you don't need that particular value during a pass. Version 1 is also more abstract, hides the details better. Version 2 is clearer about when the data is actually valid and ok to read or modify (between the load and save) because it more clearly works within the ASP.NET lifecycle. Version 2 does tend to require more boilerplate code though (a property, a backing private field, and viewstate handling in two places) as opposed to Version 1 which combines all that into one place.
i have a web for and want to 'get' it to another page.. is there anyway to submit it without posting the viewstate and other bits i dont want? or should i be catching the submit button click and redirecting with a querystring i build myself
I can tried save some data to ViewState, but i get this Error:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Error serializing value 'HeRMeSSAAS.BussinesProcess.BussinesServices.CandidateService' of type 'HeRMeSSAAS.BussinesProcess.BussinesServices.CandidateService.' Code:
private IActionService ActionService { get [code]... How i can store value to ViewState?
I have searched the web for the answer and saw that mostly variables are saved in viewstate on page.prerender event. Then the value of the variable is set back in page load event.However, when I save a variable in viewstate on prerender or load events, how can viewstate store the value of the variable after it is changed dynamically on codebehind?
Let's say, after page is loaded, user clicked a button which changes the value of the variable in its onClick event. Then the postback event raised since the button was clicked. According to me, the new value should have been lost and cannot be saved in the viewstate if the variable is saved in the viewstate only in prerender event. Because on postback the prerender event wont fire and the value cannot be saved.
Shouldn't I save the variable in the viewstate just before the postback event rises?? If so, how can viewstate store the new value of the variable if the viewstate is saved in prerender event?