Pass parameter to controller from @Html.ActionLink MVC 4
Posted
by
NetraSW
on Stack Overflow
See other posts from Stack Overflow
or by NetraSW
Published on 2013-01-04T06:57:38Z
Indexed on
2014/06/04
9:25 UTC
Read the original article
Hit count: 155
Razor
|asp.net-mvc-4
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
© Stack Overflow or respective owner