how should my Global.asax file look, and the Controller's action, to get a URL like:
http://mysite.com/name
The name
is a string - it may be anything.
I try:
Global开发者_运维技巧.asax:
routes.MapRoute(
"ViewContent", // Route name
"{name}", // URL with parameters
new { controller = "Main", action = "ViewC" } // Parameter defaults
);
MainController:
public ActionResult ViewC(string name)
{
...
}
but it doesn't "go" inside that action.
try
routes.MapRoute("Default", "{name}",
new {.controller = "Main",
.action = "ViewC",
.name = UrlParameter.Optional});
You might also want to make that controller return the view "name"
public ActionResult ViewC(string name)
{
return view(name);
}
精彩评论