[Route("ceshi/c")]
public ActionResult Index()
{
return View();
}
为什么我访问http://localhost:61103/ceshi/c 会出错,如下
难道是因为我的区域不行?我曾经测试不用区域的话,是管用的。不知道为什么用区域会出这个错误。
5 个解决方案
#1
你截图所在的目录下没找到视图
#2
你都还没创建对应的视图
#3
/*******************************************************************************
* Copyright (C) dj.wong
*
* Author: dj.wong
* Create Date: 2015/8/21
* Description: Automated building by dj.wong
*
* Revision History:
* Date Author Description
*
*********************************************************************************/
using System.Web.Mvc;
using System.Web.Routing;
namespace EP.Site.Web
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//开启特性路由
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Description", id = UrlParameter.Optional }
);
}
}
}
* Copyright (C) dj.wong
*
* Author: dj.wong
* Create Date: 2015/8/21
* Description: Automated building by dj.wong
*
* Revision History:
* Date Author Description
*
*********************************************************************************/
using System.Web.Mvc;
using System.Web.Routing;
namespace EP.Site.Web
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//开启特性路由
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Description", id = UrlParameter.Optional }
);
}
}
}
#4
我开了, 而且视图是有的,不用这个特性就能正常 访问
#5
开启特性路由的是必须的,接下里,你在的Card控制器里面,加上[RouteArea("Card")],然后把你的特性路由改成:[Route("~/ceshi/c")]
就可以通过如下的地址访问了:http://localhost:61103/ceshi/c
我已经测试过了,见下图:
就可以通过如下的地址访问了:http://localhost:61103/ceshi/c
我已经测试过了,见下图:
#1
你截图所在的目录下没找到视图
#2
你都还没创建对应的视图
#3
/*******************************************************************************
* Copyright (C) dj.wong
*
* Author: dj.wong
* Create Date: 2015/8/21
* Description: Automated building by dj.wong
*
* Revision History:
* Date Author Description
*
*********************************************************************************/
using System.Web.Mvc;
using System.Web.Routing;
namespace EP.Site.Web
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//开启特性路由
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Description", id = UrlParameter.Optional }
);
}
}
}
* Copyright (C) dj.wong
*
* Author: dj.wong
* Create Date: 2015/8/21
* Description: Automated building by dj.wong
*
* Revision History:
* Date Author Description
*
*********************************************************************************/
using System.Web.Mvc;
using System.Web.Routing;
namespace EP.Site.Web
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//开启特性路由
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Description", id = UrlParameter.Optional }
);
}
}
}
#4
我开了, 而且视图是有的,不用这个特性就能正常 访问
#5
开启特性路由的是必须的,接下里,你在的Card控制器里面,加上[RouteArea("Card")],然后把你的特性路由改成:[Route("~/ceshi/c")]
就可以通过如下的地址访问了:http://localhost:61103/ceshi/c
我已经测试过了,见下图:
就可以通过如下的地址访问了:http://localhost:61103/ceshi/c
我已经测试过了,见下图: