Edu*_*ard 3 javascript asp.net-mvc jquery routing angularjs
我试图通过源代码学习一些东西,但是当我尝试复制此代码时,却遇到了该错误。
我有一个查看索引,试图从另一个文件夹访问一些.cshtml模板。
@{
ViewBag.Title = "Index";
}
<div ng-controller="inboxIndexCtrl">
<div class="row">
<div class="col-sm-1">
<a ng-href="#/" id="InboxSubNav">Inbox</a>
<hr />
<a ng-href="#/sent" id="InboxSubNav">Sent</a>
<hr />
<a ng-href="#/create" id="InboxSubNav">Create</a>
</div>
<div class="col-sm-11">
<div class="well" ng-view></div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
脚本:
var mail = angular.module('mail', ['ngRoute']);
mail.config([
'$routeProvider', ($routeProvider) => {
$routeProvider.when('/', {
templateUrl: 'Templates/Incoming.cshtml'
})
// Registering path with controller relative to Inbox/Index
// This part is similar to RouteConfig.cs in ASP MVC
.when('/message/:id', {
// Templates are located inside Inbox.
templateUrl: 'Templates/Message.cshtml',
controller: 'oneMessageCtrl'
}).when('/create', {
templateUrl: 'Templates/Create.cshtml',
controller: 'createCtrl'
}).when('/reply/:id', {
templateUrl: 'Templates/Reply.cshtml',
controller: 'replyCtrl'
}).when('/sent', {
templateUrl: 'Templates/Sent.cshtml',
controller: 'sentCtrl'
})
.otherwise({ redirectTo: '/' });
}
]);
Run Code Online (Sandbox Code Playgroud)
_Layout已包含ng-app <html ng-app="mail">。另外,Angular捆绑软件会在Jquery之前加载,这是通过localhost完成的。
我使用的版本:
Angular 1.3.0-beta4
jquery-1.10.2
Run Code Online (Sandbox Code Playgroud)
页面加载后,将加载一秒钟,<div class="well" ng-view></div>然后消失。
当我将鼠标悬停在链接上方时,路径似乎很好。当我单击链接时,它会继续前进,但由于403错误而不会加载任何内容。
这里有一些链接:
http://localhost:49602/Messages/Index#/
http://localhost:49602/Messages/Index#/sent
http://localhost:49602/Messages/Index#/create
Run Code Online (Sandbox Code Playgroud)
我的猜测是我没有使用正确的Angular / Jquery版本,还是缺少某些软件包?
试图在浏览器中查看一个模板,但出现另一个错误:
“ /”应用程序中的服务器错误。无法提供此类页面。
说明:由于明确禁止了您请求的页面类型,因此无法提供。扩展名“ .cshtml”可能不正确。请查看下面的URL,并确保其拼写正确。
要求的网址:/Messages/Templates/Create.cshtml
在stackoverflow的帮助下,我解决了这个问题:
解决方法如下:'/'应用程序中的服务器错误。无法提供此类页面
<add key="webpages:Enabled" value="true" />
Run Code Online (Sandbox Code Playgroud)
在我的webconfig中将其设置为false
| 归档时间: |
|
| 查看次数: |
56224 次 |
| 最近记录: |