I know there are a lot other topics like this, but from what I found, and did accordingly to the answers - I still have the error.
The Global.asax:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Func", action = "Main", id = UrlParameter.Optional } // Parameter defaults
);
The Controller:
public class FuncController : Controller
{
//
// GET: /Func/
public ActionResult Main()
{
return View();
}
public ActionResult Products()
{
return View();
}
And accordingly the 2 .cshtml
View files with the Main
and Products
names. In the "Project Properties->Web" I selected "Start URL" with value "http:// localhost:63497/Main". I don't get it where might the problem be, as in the other topics I found about this error, the problem was always in some of these things. But now, everything seems to be fine, and still - error.
Main
is the Action method. You need to navigate to the Controller
and let that hit the appropriate Action. Try navigating to:
http:// localhost:63497/Func/Main
Which is Func
Controller. ActionMethod Main
try like this..
http://localhost:63497/Func/Main.
because the route is from controller to ActionResult.
so, here Func is the Controller and the Main is your ActionResult Method.
so, you have to use the controller first in url before the Action Method.
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.