I have been running a an MVC 5 site and wanted to upgrade to 5.2.3. When I install the 5.2.3 nuget package and try to run the site that was working I now get an error in the RouteCOnfig file, "routes.MapMvcAttributeRoutes();"
There is an error for every method call that has a ref parameter the error is always something like:
Cannot call action method '{what ever method has ref param}' on controller 'AllThings.WebUI.Controllers.PostController' because the parameter 'AllThings.Entities.Post& post' is passed by reference. Parameter name: methodInfo
What am I missing?
Code sample
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(null, "{controller}/{action}");
}
}
I have cut out most of the code so the ref method call can be easily seen on the setpostcoredetails call.
[Route("~/{site}/edit")]
[HttpPost]
[Authorize]
public ActionResult Edit(string site, PostViewModel postViewModel)
{
IPostRepository postRepository = contextFactory.GetPostRepository();
Post post = postRepository.Posts.FirstOrDefault(i => i.PostId == postViewModel.PostId);
SetPostCoreDetails(ref post, User.Identity.GetUserId(), postViewModel);
LoadEditUIOptions(postViewModel);
return View(postViewModel);
}
}
private void SetPostCoreDetails(ref Post post, string userId, PostViewModel postViewModel)
{
}
Aucun commentaire:
Enregistrer un commentaire