and here's what you should use:
@Html.ActionLink(
"Reply", // linkText
"BlogReplyCommentAdd", // actionName
"Blog", // controllerName
new { // routeValues
blogPostId = blogPostId,
replyblogPostmodel = Model,
captchaValid = Model.AddNewComment.DisplayCaptcha
},
null // htmlAttributes
)
Also there's another very serious issue with your code. The following routeValue:replyblogPostmodel = Model
You cannot possibly pass complex objects like this in an ActionLink. So get rid of it and also remove the BlogPostModel parameter from your controller action. You should use the blogPostId
parameter to retrieve the model from wherever this model is persisted,
or if you prefer from wherever you retrieved the model in the GET
action:public ActionResult BlogReplyCommentAdd(int blogPostId, bool captchaValid)
{
BlogPostModel model = repository.Get(blogPostId);
...
}
As far as your initial problem is concerned with the wrong overload I
would recommend you writing your helpers using named parameters:@Html.ActionLink(
linkText: "Reply",
actionName: "BlogReplyCommentAdd",
controllerName: "Blog",
routeValues: new {
blogPostId = blogPostId,
captchaValid = Model.AddNewComment.DisplayCaptcha
},
htmlAttributes: null
)
Now not only that your code is more readable but you will never have
confusion between the gazillions of overloads that Microsoft made for
those helpers.I have already assign a value for this on top such as
@{
var blogPostId = Model.Id;
}
My Controller: public ActionResult BlogReplyCommentAdd(int blogPostId, BlogPostModel model, bool captchaValid)
{}


0 comments:
Post a Comment
Note: only a member of this blog may post a comment.