`First, this is my first MVC code & I tried to search for the solution to the problem in this site & I checked all the possible cases like routeconfig file, controller,action properties & I tried to put appropriate values in specified page of Web Tab of Project Property. But still it showing the same error. Some help please.
here my routeconfig file
namespace Deepak_MVC_2
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Student", action = "GetStudents", id = UrlParameter.Optional }
);
}
}
}
specific page entry : Student/GetStudents
namespace Deepak_MVC_2.Controllers
{
public class StudentController : Controller
{
public ActionResult GetAllStudent()
{
StudentModelManager smm = new StudentModelManager();
List<StudentModel> lsm = smm.GetAllStudentInfo();
ActionResult ar = View("GetStudents",lsm);
return ar;
}
}
}
Update your controller's action to match the View you want. with that You can actually remove the name when returning the view as convention will match the ViewName
to the action name.
namespace Deepak_MVC_2.Controllers
{
public class StudentController : Controller
{
public ActionResult GetStudents()
{
StudentModelManager smm = new StudentModelManager();
List<StudentModel> lsm = smm.GetAllStudentInfo();
ActionResult ar = View(lsm);
return ar;
}
}
}
this will allow
GET /Student/GetStudents
to be matched to the correct view as in your image
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.