我有一个MVC测试项目,我正在研究是否可以让角路由使用它。使用ASP MVC的角度路由
我的意思与它的工作,我希望能够有一个着陆页我的应用程序:www.testapp.com
然后,当人们登录我想MVC将它们路由到testapp.com/Dashboard/#/
,然后我想能够使用NG-观点与Angualar加载页面,像这样: testapp.com/Dashboard/#/PageOne
,testapp.com/Dashboard/#/PageTwo
等
这是我曾尝试: main.js:
angular.module('App', ['ngRoute', 'ngResource']);
angular.module('App').config(function ($routeProvider) {
$routeProvider
.when('/Dashboard', {
templateUrl: 'Dashboard/Index'
})
.when('/PageOne', {
templateUrl: 'Dashboard/PageOne'
})
});
~/Views/Home/Index.cshtml
是没有用角路由,刚刚ActionLinks登录并注册了目标网页
〜/查看/仪表板/ Index.cshtml就是我曾经NG-应用和NG-观点,我不得不像这样的链接:<a href="/#/Dashboard">Dashboard</a>
,<a href="/#/PageOne">Page One</a>
的问题是,当我去testapp.com/Dashboard时加载的网址变成testapp.com/Dashboard#/
而不是testapp.com/Dashboard/#/
的另一个问题是,当我点击我的链接,它直接回到主页/索引,网址如下所示:testapp.com/#/PageOne
但首页正在显示在我的RouteConfig.cs
文件,它只是默认:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
所以我的问题是什么是错在这里我的代码,使得它无法正常工作像我希望它?我必须添加/更改什么?
谢谢!