asp.net mvc - How to prevent cross site scripting in MVC when AJAX request is sent by another website -


i have html form in mvc asp.net user fills out , request goes server [ajax] send mail them inform them. use hidden key store information on page.

i find changed key , clicked it's problem mail go other unknown case.

how can sure nobody changes hidden key , request valid. thing want html. antioforeignkey suitable that.

but how can implement antiforeignkey when send ajax request server.

are there tricks solve problem in mvc?

check out link: http://blog.stevensanderson.com/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/

this link antiforgerytoken , ajax calls: http://blogs.us.sogeti.com/swilliams/2009/05/14/mvc-ndash-using-antiforgerytoken-over-ajax/

be sure add @html.antiforgerytoken() form can use jquery pull value. value can add data attribute of jquery ajax call.

var token = $('input[name=__requestverificationtoken]').val(); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -