tags:

views:

95

answers:

1

In ASP.NET, the ViewState is typically protected from tampering on the client with a signature generated by the machine secret on the server. But this protection can be easily turned off with:

<%@ Page ... EnableViewStateMac="false" %>

I'm writing an ASP.NET control that may store security-sensitive information (not secret... but it must not be tampered with), depending on whether EnableViewStateMac is true.

How can I test to see whether it's on or off at runtime?

+2  A: 

You should just be able to reference

Page.EnableViewStateMac

From within your code.

http://msdn.microsoft.com/en-us/library/system.web.ui.page.enableviewstatemac.aspx

Mel Harbour
Wow. This just goes to show that if something doesn't exist in Intellisense, some developers don't think it exists at all. It's a perfect spot for that property to go, and yet that property has `[EditorBrowsable(EditorBrowsableState.Never)]` set on it so that Intellisense doesn't expose it.Anyway, thanks!
Andrew Arnott