My MVC controller named as ''UserController''. Index action being called but I am getting the error as
{"Message":"No HTTP resource was found that matches the request URI /user/home'.","MessageDetail":"No type was found that matches the controller named 'home'."}
Member
12 Points
16 Posts
MVC 4 controller not working
Jan 12, 2019 08:37 AM|Robert John|LINK
Hi all,
My MVC controller named as ''UserController''. Index action being called but I am getting the error as
{"Message":"No HTTP resource was found that matches the request URI /user/home'.","MessageDetail":"No type was found that matches the controller named 'home'."}
My routing code as
Anyone can please help me to find out the problem! Thanks.
Member
710 Points
113 Posts
Re: MVC 4 controller not working
Jan 12, 2019 08:45 AM|rubaiyat2009@gmail.com|LINK
Hi
can you please send your controller code? Thanks
Member
12 Points
16 Posts
Re: MVC 4 controller not working
Jan 12, 2019 08:49 AM|Robert John|LINK
public class UserController : Controller
{
//
// GET: /User/
public ActionResult Index()
{
return View();
}
public ActionResult Add()
{
return View();
}
public ActionResult Update()
{
return View();
}
public ActionResult Delete()
{
return View();
}
}
Member
710 Points
113 Posts
Re: MVC 4 controller not working
Jan 12, 2019 08:52 AM|rubaiyat2009@gmail.com|LINK
A method in a Controller that returns a
string
will not be routable. It must return anActionResult
(or one of it's derived classes).Change it to:
Then in your Views/Home folder, add a view called Home that has something like:
Please don't forget to mark as answer if it helps you. Thanks!
Member
12 Points
16 Posts
Re: MVC 4 controller not working
Jan 12, 2019 09:33 AM|Robert John|LINK
Yes it is! Thanks rubaiyat2009.