【发布时间】:2013-05-04 12:15:57
【问题描述】:
角度路线:
angular.module('AMS', []).
config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/dashboard', { templateUrl: '/Dashboard', controller: dashboardController }).
when('/settings', { templateUrl: '/Settings', controller: settingsController }).
otherwise({ redirectTo: '/dashboard' });
}]);
示例:
/* client side route */
http://localhost:4117/#/dashboard
指向
/* controller that returns the partial */
http://localhost:4117/Dashboard
一切都按预期工作,但如果我将相同的 url 放入浏览器(没有前导 /#/),部分仍然会返回,这不好。
如何防止这种情况发生?
【问题讨论】:
-
Ghetto 装配方式:没有返回视图的索引操作,但这感觉不对,即使它有效。此外,它只能防止意外查看,因为任何人都可以转到路由配置并查看 ASP.NET MVC 路由。
标签: asp.net-mvc angularjs asp.net-mvc-routing