我有一个MVC web应用程序,我正在工作,其中一个页面使用javascript文件的数据。
I have the TournamentInfo.js file in a folder called "Scripts"
I have the TournamentController.cs file in a folder called "Controllers"
I have the TourneyInfo.cshtml file in a folder called "Tourneys" that is in a folder called "Views"当我试图运行该项目时,我会得到以下错误:
[Htpp Exception] The controller for path '/Tourneys/TourneyInfo' was not found or does not implement IController我的项目中有另一个使用相同格式设置的页面(javascript文件、控制器文件和视图文件),该页面可以正常工作。我找不到会导致我所收到的错误的区别。
对于我应该寻找什么来解决我的锦标赛页面上的问题有什么建议吗?
*如果您想查看每个文件的代码,请告诉我。我不确定它是否相关,因为我的另一个页面使用这种格式有效。
Javscript文件:
function tournamentpageModel() {
var self = this;
self.Tournaments = ko.observableArray([]);
}
function TourneyInfo(_name, _date, _location, _pattern, _avg, _finish, _ttlentries) {
var self = this;
self.Name = ko.observable(_name);
self.Date = ko.observable(_date);
self.Loc = ko.observable(_location);
self.Pattern = ko.observable(_pattern);
self.Avg = ko.observable(_avg);
self.Finish = ko.observable(_finish);
self.Entries = ko.observable(_ttlentries);
}
var viewTModel = new tournamentpageModel();
viewTModel.Tournaments.push(new TourneyInfo("South Regional", "May 9-10, 2014", "Rocky Mount, NC", "Chameleon (41ft)", "167.75", "70th", "75"));
viewTModel.Tournaments.push(new TourneyInfo("South Regional", "March 7-9, 2014", "Pensacola, FL", "Badger (52ft)", "215.75", "17th", ""));
viewTModel.Tournaments.push(new TourneyInfo("South Regional", "", "Pensacola, FL", "", "", "", ""));
viewTModel.Tournaments.push(new TourneyInfo("South Regional", "", "Canton, GA", "Viper (39ft)", "215.75", "14th", ""));
$(function () {
ko.applyBindings(viewTModel);
})主计长:
using PracticeApp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace PracticeApp.Controllers
{
public class TournamentController : Controller
{
public ActionResult TourneyInfo()
{
return View();
}
}
}查看:
<script src="@Url.Content("~/Models/TournamentInfo.js")" type="text/javascript"></script>
@{
ViewBag.Title = "Tournaments";
}
<hgroup class="title">
<h1>@ViewBag.Title</h1>
</hgroup>
<table id="sponsorTable">
<!-- Todo: Generate table body -->
<tbody data-bind="foreach: TourneyInfo">
<tr>
<th>Tournament Name</th><th>Date</th><th>Location</th><th>Oil Pattern</th><th>Quailfying Avg</th><th>Finished</th><th>Total Entries</th>
</tr>
<tr>
<td class="sTableInfo" data-bind="text: Name"></td>
<td class="sTableInfo" data-bind="text: Date"></td>
<td class="sTableInfo" data-bind="text: Loc"></td>
<td class="sTableInfo" data-bind="text: Pattern"></td>
<td class="sTableInfo" data-bind="text: Avg"></td>
<td class="sTableInfo" data-bind="text: Finish"></td>
<td class="sTableInfo" data-bind="text: Entries"></td>
</tr>
</tbody>
</table>共享layout....contains导航菜单的操作链接。他们都工作,除了比赛链接。它们在重载中都使用相同的格式(“超链接文本”、“文件名”、“文件夹名”):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Atlas Web Pages</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<script src="@Url.Content("~/Scripts/knockout-2.1.0.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>
</head>
<body>
<header id="header">
<div class="web-header">
<div class="logo-image">
<img src="~/Images/Atlas.png" style="float: left" height="125" width="150" alt="Atlas Logo" />
<img style="vertical-align:top" src="~/Images/WebPageLogo.png" height="85" width="820" alt="Atlas Logo" />
<div style="color:#FFF">*A southpaw's approach to bowling*</div>
</div>
<div class="float-right">
<nav>
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("The Team", "About", "About")</li>
<li>@Html.ActionLink("Current Line-Up", "CurrentList", "Current")</li>
<li>@Html.ActionLink("Retired Equipment", "RetiredList", "Retired")</li>
<li>@Html.ActionLink("Tournaments", "TourneyInfo", "Tourneys")</li>
<li>@Html.ActionLink("Bowling Videos", "Videos", "Video")</li>
<li>@Html.ActionLink("Sponsors", "Sponsors", "Sponsor")</li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<footer>
<div id="footer">
<div class="content-wrapper">
<div class="float-left">
<p>© @DateTime.Now.Year: Southpaw Web Solutions™ - Email: jmilam90@gmail.com</p>
<p>Stylized drawing of the god, Atlas, courtesy of shutterstock</p>
</div>
<div id="follow-icons">
<a href ="www.facebook.com/jmilam90"><img src="~/Images/FBIcon.png" alt="Follow on Facebook" height="40" width="40" /></a>
<a href ="www.twitter.com/jmilam900"><img src="~/Images/TwitIcon.png" alt="Follow on twitter" height="40" width="40" /></a>
</div>
</div>
<table id="logo-table">
<tr>
<td>
<img src="~/Images/MBW.png" width="99" height="60" alt="McCorveys Bowling World Logo" />
</td>
<td>
<img src="~/Images/EboniteLogo.png" width="93" height="60" alt="Ebonite Logo" />
</td>
<td>
<img src="~/Images/TrackLogo.png" width="152" height="60" alt="Track Bowling Logo" />
</td>
<td>
<img src="~/Images/HammerLogo.png" width="100" height="60" alt="Hammer Bowling Logo" />
</td>
<td>
<img src="~/Images/ColumbiaLogo.png" width="123" height="60" alt="Columbia 300 Logo" />
</td>
<td>
<img src="~/Images/PBALogo.png" width="60" height="60" alt="PBA Logo" />
</td>
</tr>
</table>
</div>
</footer>
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>发布于 2014-06-11 12:34:25
约定是让路径使用控制器名称的前缀,因此您应该导航到:
/Tournament/TourneyInfo/而不是:
/Tourneys/TourneyInfo/您可能会发现,在报告失败之前,确定尝试了哪些路由是有用的:
http://getglimpse.com/
编辑:也见下面的评论。另一个问题是视图的位置--默认情况下,视图需要位于Views\<ControllerName>\文件夹中,例如Views\Tournament\。
https://stackoverflow.com/questions/24163011
复制相似问题