Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 路由mvc4应用程序_Asp.net Mvc - Fatal编程技术网

Asp.net mvc 路由mvc4应用程序

Asp.net mvc 路由mvc4应用程序,asp.net-mvc,Asp.net Mvc,到目前为止,我在寻找工作路线时遇到了一些困难 routes.MapRoute("Stores","{s}",new { controller = "Stores", action = "Index", s = UrlParameter.Optional}); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", de

到目前为止,我在寻找工作路线时遇到了一些困难

    routes.MapRoute("Stores","{s}",new { controller = "Stores", action = "Index", s = UrlParameter.Optional});

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            constraints: null,
            namespaces: new[] { "NS.Web.Controllers" }
        );
我试图通过/stores/store abc浏览到控制器,但是我得到了404

我的路线有什么问题

任何帮助都将不胜感激

我的路线有什么问题

您的路由定义与您正在使用的url模式不匹配:

routes.MapRoute(
    "Stores", 
    "stores/{s}", 
    new { 
        controller = "Stores", 
        action = "Index", 
        s = UrlParameter.Optional 
    }
);
您的
存储
控制器:

public class StoresController : Controller
{
    public ActionResult Index(string s)
    {
        return View();
    }
}