【发布时间】:2016-04-05 21:10:19
【问题描述】:
我有一个 Angular MVC 应用程序,它有几个控制器。默认和我添加的另一个自定义控制器。
http://example.com/home/
http://example.com/ManageSummaryInfo/
我所有的业务逻辑都依赖于ManageSummaryInfo Controller。
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "ManageSummaryInfo", action = "HomePage", id = UrlParameter.Optional }
);
在 Angular 路由中,我有这样的,
$routeProvider.when('/showsummary',
{
templateUrl: 'ManageSummaryInfo/ShowSummary',
controller: 'ShowSummaryController'
});
$routeProvider.when('/showerror',
{
templateUrl: 'ManageSummaryInfo/ShowError',
controller: 'ShowErrorController'
});
$routeProvider.when('/showplatform',
{
templateUrl: 'ManageSummaryInfo/ShowPlatform',
controller: 'ShowPlatformController'
});
我的视图也是围绕ManageSummaryInfo 控制器配置的,但是当我运行时,我会进入主页,然后单击其中一个元素会转到下一页。但是,我没有被路由,我得到了 404 - The resource cannot be found.error。
这就是我的观点,
Views
--ManageSummaryInfo
----HomePage.cshtml
----Index.cshtml
----ShowSummary.cshtml
----ShowError.cshtml
----ShowPlatform.cshtml
我的问题是,当我们的路由中有控制器时(即,http://example.com/ManageSummaryInfo/- Angular 将如何路由事物以及为什么我的获取文件未找到错误。
我是 C# MVC 框架的新手。我是否缺少与 ASP.NET Routing 相关的内容?任何帮助将不胜感激。我试图详细说明,但如果您需要更多信息,我很乐意提供更多代码(Pastebin 或其他东西。
提前致谢!
编辑:
根据要求添加控制器类,
public class ManageSummaryInfoController : Controller
{
// GET: ManageSummaryInfo
public ActionResult Index()
{
return View();
}
public ActionResult HomePage()
{
return View();
}
public ActionResult ShowPlatform()
{
return PartialView("ShowPlatform");
}
public ActionResult ShowSummary()
{
return PartialView("ShowSummary");
}
public ActionResult ShowError()
{
return PartialView("ShowError");
}
}
【问题讨论】:
-
你的 menageSummaryInfoController 是什么样子的?
标签: angularjs asp.net-mvc asp.net-mvc-4 asp.net-mvc-routing angularjs-routing