c# - ASP.NET MVC: does AntiForgeryToken work in mono? -
i'm trying use html.antiforgerytoken in asp.net mvc under mono (xsp) , not work. throws following exception. ideas?
system.argumentnullexception: argument cannot null. parameter name: inputstring @ system.web.ui.objectstateformatter.deserialize (system.string inputstring) [0x00006] in /home/danipen/downloads/mono-2.8/mcs/class/system.web/system.web.ui/objectstateformatter.cs:131 @ system.web.ui.hiddenfieldpagestatepersister.load () [0x00007] in /home/danipen/downloads/mono-2.8/mcs/class/system.web/system.web.ui/hiddenfieldpagestatepersister.cs:57 @ system.web.ui.page.loadpagestatefrompersistencemedium () [0x0000f] in /home/danipen/downloads/mono-2.8/mcs/class/system.web/system.web.ui/page.cs:1763 @ system.web.ui.page.loadpageviewstate () [0x00000] in /home/danipen/downloads/mono-2.8/mcs/class/system.web/system.web.ui/page.cs:1769 @ system.web.ui.page.restorepagestate () [0x00051] in /home/danipen/downloads/mono-2.8/mcs/class/system.web/system.web.ui/page.cs:1454 @ system.web.ui.page.internalprocessrequest () [0x001b9] in /home/danipen/downloads/mono-2.8/mcs/class/system.web/system.web.ui/page.cs:1433 @ system.web.ui.page.processrequest (system.web.httpcontext context) [0x0005b] in /home/danipen/downloads/mono-2.8/mcs/class/system.web/system.web.ui/page.cs:1261 do know other way implement this?
thanks in advanced.
edit: view code (it's partial view). if remove line <%= html.antiforgerytoken() %> works fine, in other case thows exception described above.
<%@ control language="c#" inherits="system.web.mvc.viewusercontrol<codice.web.client.comment>" %> <div class="comment" style="background-color: #009acf"> <div class="comment-meta"> <p class="comment-author"> <span class="avatarimage"> <%= html.avatarfor(model.commentinfo.owner) %> </span> <strong class="comment-author"> <%= html.encode(model.getauthorstring()) %> </strong> says: </p> <p class="comment-date"> <%= html.timeago(model.commentinfo.localtimestamp) %> </p> </div> <div class="comment-body"> <div class="formatted-content"> <%= html.encode(model.commentinfo.comment) %> </div> <div class="form-content"> <% using(html.beginform( "editcomment", "comments", new { repository = model.repository, commentid = model.commentinfo.id }, formmethod.post, null)) { %> <%= html.antiforgerytoken() %> <%= html.textbox("newcomment", model.commentinfo.comment) %> <div class="form-actions"> <a class"edit-cancel minibutton" href="#"> <span>cancel</span> </a> <button class="minibutton" type="submit"> <span>update comment</span> </button> </div> <% } %> </div> </div> </div>
do have [validateantiforgerytoken] attribute set on controller action serving post verb?
edit: possible solution issue using newest mono master branch, because problem can replicated on older versions of mono (for example tarball april 22 causing same exception).
edit 2: needed working setting valid machinekey element in web.config file. keys can generated example this utility.
Comments
Post a Comment