ThemeGroups リストからメニューを表示するレイアウトがあります。メニュー項目の 1 つをクリックすると、この ThemeGroup 内のすべてのテーマを表示するページに移動するはずですが、そうすると、次のエラーが発生します。
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarilyunavailable.
Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Home/Browse/1
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.225
テーマのプロパティを提供する「ThemeModel.cs」、「id」と「ThemeGroupName」を提供する「ThemeGroupsModel.cs」があり、クラス「ThemeSrv. cs」。このクラスには、次のコードを持つ 1 つのメソッドがあります。
public List<ThemesModel> getAllTheme(short ThemeGrId)
{
List<ThemesModel> ThemeList = new List<ThemesModel>();
ThemesModel themeTemp;
using (var context = new EShopThemeDBEntities(idbconnection.ConnStr))
{
var ThemesDb = (from o in context.Themes
where o.ThemeGroupId == ThemeGrId
select o).ToList();
if (ThemesDb != null)
{
foreach (var item in ThemesDb)
{
themeTemp = new ThemesModel();
themeTemp.ThemeID = item.ThemeID;
themeTemp.ThemeName = item.CodeName;
themeTemp.HtmlF = item.Html;
themeTemp.JoomlaF = item.Joomla;
themeTemp.Image = item.Image;
themeTemp.PsdF = item.PSD;
themeTemp.UploadDate = item.UploadDate;
themeTemp.UnitPrice = (float)item.UnitPrice;
ThemeList.Add(themeTemp);
}
}
}
return ThemeList;
}
これらのプロパティを持つ HomeModel があります。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EshopTheme.Services;
namespace EshopTheme.Models
{
public class HomeModel
{
public MenuSrv MenuList { get; set; }
public IEnumerable<ThemeGroupsModel> ThemeGr { get; private set; }
public ThemeSrv ThemesByGrId { get; set; }
public IEnumerable<ThemesModel> AllThemes { get; private set; }
public HomeModel()
{
this.MenuList = new MenuSrv();
this.ThemeGr = this.MenuList.getAllThemeGroup();
this.ThemesByGrId = new ThemeSrv();
this.AllThemes = ThemesByGrId.getAllTheme(2);
}
これは HomeController での私のアクションです。
[HttpPost]
public ActionResult Browse(short ThemeGroupId)
{
var themes = new ThemeSrv();
return View(themes.getAllTheme(ThemeGroupId));
}
これらのコードは、すべてのページにメニューを表示するために「_LayoutMain.cshtml」にあります。
@{EshopTheme.Models.HomeModel hm = new EshopTheme.Models.HomeModel();
}
<ul id="menu">
@foreach (var item in hm.ThemeGr)
{
<li>
@Html.ActionLink(item.ThemeGroupName, "Browse", "Home",
new { id = item.ThemeGroupId }, new { @class = "linkMenu" })
</li>
} </ul>
"Brows.cshtml" という名前の "Browse" アクションのビューを作成して、メニューの 1 つの項目 ("sport" などのテーマ グループの 1 つ) をクリックしたときに結果を表示します。グループという名前のすべてのテーマのリストが表示されます。 "スポーツ"。
@{ EshopTheme.Models.HomeModel hm = new EshopTheme.Models.HomeModel();
ViewBag.Title = "Browse";
Layout = "~/Views/Shared/_LayoutMain.cshtml";
}
<ul id="themeList">
@foreach (var item in hm.ThemesByGrIds )
{
<li><a href="@Html.ActionLink(item.ThemeName, "Browse", "home",
new { id=item.ThemeID })">
<img src="@item.Image" alt="@item.ThemeName" /><br />
<span>Theme Name: @item.ThemeName </span>
<br /><span>Upload date: @item.UploadDate
</span>
@* <span>price: @item.UnitPrice</span>*@
</a></li>
}
私の問題は何ですか?? 助けてくれてありがとう...