Last post May 10, 2017 06:15 AM by Edward Z
May 09, 2017 11:52 PM|NewToDotyNet|LINK
Hi. I am new to MVC Core.
I have been attempting to get an edit blog working.
The code is at - https://github.com/DotNetDS/CoreMVC_Project.git
In the blog controller I have two edit methods.
I have commented the first one out so I can get to the blog page without an error and the edit does not work anyway.
On the blog page there is a html edit tag which I would like to take the site to an edit page.
Where the blog data can be edited. I have been struggling to find a tutorial to show me this exactly.
The error is (when uncommented).
May 10, 2017 01:30 AM|JBetancourt|LINK
Normally you dont pass an ExploreCalifornia parameter to Index, Index normally display a list of ExploreCalifornias therefore it doesnt need an ExploreCalifornia parameter.
The app is confused on which of the 2 routes you want to use
Wait but looking at your source code the parameters you have are Index(int page) and Edit(int Id). Still you cannot have the same parameters for the 2 methods. Do this, add another parameter to Index(int page, int pageSize)
if that doesnt work then hardcode the edit route as:
May 10, 2017 05:16 AM|NewToDotyNet|LINK
Hi, had to use the second option
(Edit still does not work).
May 10, 2017 06:15 AM|Edward Z|LINK
Did you get create method work?
I think you need to change like below:
public async Task<IActionResult> Edit(int id)
if (id.ToString() == null)
var post = await _db.Posts.SingleOrDefaultAsync(m => m.Id == id);
if (post == null)
public async Task<IActionResult> Edit(int Id, [Bind("Id,Key,Author,Title,Posted,Body")] Post post)
if (Id != post.Id)
I am not sure why you used m.key to compare Id. You need to use m.Id instead of m.key.