Archive for March 5, 2009

Tweaking the AntiForgeryToken on ASP.Net MVC RC2   Leave a comment

After a bit of thought I realised that my old helper extension method to set the path of the anti-forgery cookie was broken by RC2. Steve Sanderson did point out that they now allow you to specify the path up front when you create the token though so it actually makes my helper even simpler.

public static string MyAntiForgeryToken(this HtmlHelper helper, string salt)
{
    string fragment = helper.AntiForgeryToken(salt, null, helper.ViewContext.HttpContext.Request.ApplicationPath);
    return fragment;
}

Posted March 5, 2009 by colinnewell in Programming

Follow

Get every new post delivered to your Inbox.

Join 32 other followers