I have a controller named as UserController and in that only Index action is being called another action added like as 'home action' is not being called and either calling actionresult/string or returning view
I am getting this error
while running at Google Chrome
{"Message":"No HTTP resource was found that matches the request URI /user/home'.","MessageDetail":"No type was found that matches the controller named 'home'."}
And running at Mozilla Firefox
Whoops! The page could not be found. Try giving it another chance below.
Here is my whole Controller Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Mvc4Application1.Controllers
{
    public class UserController : Controller
    {
        //
        // GET: /User/
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult AddPlace()
        {
            return View();
        }
        public ActionResult UpdatePlace()
        {
            return View();
        }
        public ActionResult DeletePlace()
        {
            return View();
        } 
    }
}
Here is RouteConfig.cs file
 routes.MapRoute(
     name: "Default",
      url: "{controller}/{action}/{id}",
 defaults: new 
{ controller = "Home", action = "Index",
  id=UrlParameter.Optional }
                A method in a Controller that returns a string will not be routable. It must return an ActionResult (or one of it's derived classes).
Change it to:
public ActionResult Home()
{
    return View("Hello from home");
}
Then in your Views/Home folder, add a view called Home that has something like:
@model string
<p>@Model</p>
                        Here are the following things you need to cross check
Make sure Routeconfig has proper Maproute
Else you need to rename the controller [sounds weird but it might help]
and use ActionResult as return datatype
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With