views:

235

answers:

2

Does setting enableviewstatemac to "true" affects the site's performance? Could you give me some explanation?

+1  A: 

Yes, it will affect the site's performance, straight from MSDN:

A view-state MAC is an encrypted version of the hidden variable that a page's view state is persisted to when sent to the browser. If true, the encrypted view state is checked to verify that it has not been tampered with on the client. Do not set EnableViewStateMac to true if performance is a key consideration.

That check has to do something, and something is more expensive than nothing. The larger the viewstate you're dealing with, the more overhead this will put on your requests. That being said, unless you're a really high traffic site or have really large viewstate in your pages, you probably won't notice a thing server-side. On the client however, they will be getting a larger page, which will probably have more of an impact than anything. That means they're uploading more to the server on postback...that's most likely your pain point caused by enabling this.

Keep in mind just how many things happens when the server executes a page, all of these options are "drop in the bucket" scenarios in most cases, there are of course exceptions. Current servers are powerful enough that settings like this typically don't make any noticeable impact individually, but there are of course those cases where it does, if for example you have megabytes of viewstate for some reason.

Nick Craver
A: 

The enableviewstatemac property is used to specify that upon the receipt of each client request that a check is performed to ensure that the client has not tampered with the control / hidden data that they were served.

This is important as ASP .Net uses a stateless mechanism and relies on the changes that occur on the client side being passed back as instructions to the page upon a postback to determine what changes / events have fired. If the client were able to tamper with these with impunity then they could potentially alter the page behaviour to their own means.

Brian Scott