Pass parameter to controller from @Html.ActionLink MVC 4
- by NetraSW
Hello All,
@Html.ActionLink("Reply", "BlogReplyCommentAdd", "Blog",
new { blogPostId = blogPostId, replyblogPostmodel = Model,
captchaValid = Model.AddNewComment.DisplayCaptcha })
In above line: I get error on blogPostId.
The parameters dictionary contains a null entry for parameter
'blogPostId' of non-nullable type 'System.Int32' for method
'System.Web.Mvc.ActionResult BlogReplyCommentAdd(Int32,
Nop.Web.Models.Blogs.BlogPostModel, Boolean)' in
'Nop.Web.Controllers.BlogController'. An optional parameter must be a
reference type, a nullable type, or be declared as an optional
parameter. Parameter name: parameters
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)
{}
M i doing something wrong? Please give me an example on this.
Thanks