Tweaking the AntiForgeryToken on ASP.Net MVC RC2

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;
}

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 58 other followers