框架用的Area,分了mms,psi,sys三个区域
结构如下图
我在mms区域的Controller里面添加了一个UploadController.cs控制器
然后在View的Upload文件夹下新建了Index.cshtml视图
但是浏览http://localhost:26866/mms/upload/却提示404找不到资源?
是不是和area的使用有关系?我很久不用MVC了,之前也没用过area只知道他的作用,请各位指点小弟
还有一个问题,我登录系统点击菜单的连接,跳转的地址都是类似
http://localhost:26866/#!/mms/upload的格式(但是F12检查页面实际访问的地址没有带#!),url中这个#!是什么意思?
4 个解决方案
#1
网上查了和这个有关MmsAreaRegistration.cs
但是我在地址栏输入http://localhost:26866/api/mms/upload
会提示
但是我在地址栏输入http://localhost:26866/api/mms/upload
会提示
<Error>
<Message>
No route providing a controller name was found to match request URI 'http://localhost:26866/api/mms/upload'
</Message>
</Error>
public class MmsAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Mms";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
this.AreaName + "default",
this.AreaName + "/{controller}/{action}/{id}",
new { area = this.AreaName, controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] { "Zephyr.Areas."+ this.AreaName + ".Controllers" }
);
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
this.AreaName + "Api",
"api/" + this.AreaName + "/{controller}/{action}/{id}",
new { area = this.AreaName, action = RouteParameter.Optional, id = RouteParameter.Optional, namespaceName = new string[] { string.Format("Zephyr.Areas.{0}.Controllers", this.AreaName) } },
new { action = new StartWithConstraint() }
);
}
}
#2
http://localhost:26866/api/mms/upload
/Index
#3
http://localhost:26866/mms/upload
/Index
#4
你还没建立 UploadController吧?
#1
网上查了和这个有关MmsAreaRegistration.cs
但是我在地址栏输入http://localhost:26866/api/mms/upload
会提示
但是我在地址栏输入http://localhost:26866/api/mms/upload
会提示
<Error>
<Message>
No route providing a controller name was found to match request URI 'http://localhost:26866/api/mms/upload'
</Message>
</Error>
public class MmsAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Mms";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
this.AreaName + "default",
this.AreaName + "/{controller}/{action}/{id}",
new { area = this.AreaName, controller = "Home", action = "Index", id = UrlParameter.Optional },
new string[] { "Zephyr.Areas."+ this.AreaName + ".Controllers" }
);
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
this.AreaName + "Api",
"api/" + this.AreaName + "/{controller}/{action}/{id}",
new { area = this.AreaName, action = RouteParameter.Optional, id = RouteParameter.Optional, namespaceName = new string[] { string.Format("Zephyr.Areas.{0}.Controllers", this.AreaName) } },
new { action = new StartWithConstraint() }
);
}
}
#2
http://localhost:26866/api/mms/upload
/Index
#3
http://localhost:26866/mms/upload
/Index
#4
你还没建立 UploadController吧?