I am trying to find out why the routing of these two sittuations are not functioing. I want to conver this rout in the Routes.config file to a route attribute. It needs to be a default, because when you just load the site, without any url entered, it needs to hit /Home/Index action.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
I added this to the Home controller for the actionResult Index(), but it didn't work. Said no document loaded.
[Route]
[Route("~/", Name = "default")]
public ActionResult Index()
{
var environmentsSharedAccounts = new List<EnvironmentSharedAccountVM>();
return View(environmentsSharedAccounts);
}
Why does this now not resolve. Thanks in advance. BTW. I am finding, that the books I have read, and the examples I have seen are seeming to be more compleicated to me then I thought I guess, because this routing has been giving me issues. I think I understand it, but it doesn't work how expected. Anyways....
Try
[Route("")]
public ActionResult Index()
....
Do you have this line on WebApiConfig.cs :
config.MapHttpAttributeRoutes();
?
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.