[英]Route/redirect to default action by calling the controler in url?
URL : 本地主機:4835/登錄
public class LoginController : Controller
{
public ActionResult Index()
{ 'enter code here' }
}
我想在不提及行動名稱的情況下調用 index 。
您的RouteConfig
文件中應該有這樣的RouteConfig
:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Your Default Controller Name", action = "Default Action name(usually Index)", id = UrlParameter.Optional }
);
您可以擁有自己的映射,這里只是提供了一個示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.