Если вы можете получить доступ к странице, вы можете использовать свойство ViewStateUserKey страницы. Вот пример того, как сделать это изнутри страницы, но вы получите идею:
protected void Page_Init(object sender, EventArgs e)
{
// Validate whether ViewState contains the MAC fingerprint
// Without a fingerprint, it's impossible to prevent CSRF.
if (!this.Page.EnableViewStateMac)
{
throw new InvalidOperationException(
"The page does NOT have the MAC enabled and the view" +
"state is therefore vulnerable to tampering.");
}
this.ViewStateUserKey = this.Session.SessionID;
}
В то время как ViewStateUserKey довольно безопасен, с этим есть некоторые недостатки. Вы можете прочитать больше об этом здесь .