2
我想在Mono(XSP)下的ASP.NET MVC中使用Html.AntiForgeryToken
,但它不起作用。它引發以下異常。有任何想法嗎?ASP.NET MVC:AntiForgeryToken在單聲道中工作嗎?
System.ArgumentNullException: Argument cannot be null.
Parameter name: inputString
at 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
at System.Web.UI.HiddenFieldPageStatePersister.Load() [0x00007] in /home/danipen/Downloads/mono-2.8/mcs/class/System.Web/System.Web.UI/HiddenFieldPageStatePersister.cs:57
at System.Web.UI.Page.LoadPageStateFromPersistenceMedium() [0x0000f] in /home/danipen/Downloads/mono-2.8/mcs/class/System.Web/System.Web.UI/Page.cs:1763
at System.Web.UI.Page.LoadPageViewState() [0x00000] in /home/danipen/Downloads/mono-2.8/mcs/class/System.Web/System.Web.UI/Page.cs:1769
at System.Web.UI.Page.RestorePageState() [0x00051] in /home/danipen/Downloads/mono-2.8/mcs/class/System.Web/System.Web.UI/Page.cs:1454
at System.Web.UI.Page.InternalProcessRequest() [0x001b9] in /home/danipen/Downloads/mono-2.8/mcs/class/System.Web/System.Web.UI/Page.cs:1433
at 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
你知道實現這個任何其他方式?
謝謝先進。
編輯:這是我的視圖代碼(這是部分視圖)。如果我刪除行<%= Html.AntiForgeryToken() %>
所有工作正常,在其他情況下,它會引發上述異常。
<%@ 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>
你檢查了相同的代碼在MS .NET下工作嗎? – 2010-12-03 11:11:36
我在Apache mod_mono上託管的MVC webapp中使用AntiForgeryToken,它的工作原理沒有問題。你可以通過你的視圖和控制器代碼? – yojimbo87 2010-12-03 11:34:32