エリアでルート属性を使用しています。
私のルート構成は次のとおりです。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "Peacock.Controllers" }
);
routes.MapRoute(
"CMS",
"CMS/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "CMS.Controllers" }
);
}
私のローカルでは、すべてが正しいです!今日、プロジェクトを公開してホストにアップロードしたときに、2 種類のエラーに直面しました。
Default MapRoute の URL を要求すると、mysite.com/Contents/1060
すべてが正しいように! しかし、自分の地域の URL を要求すると、2 種類のエラーに直面しました。
1) いくつかのリクエストには、次のようなエラーmysite.com/cms/comment
またはmysite.com/cms/category
エラーがあります:
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Areas/CMS/Views/ContentCategory/Index.aspx
~/Areas/CMS/Views/ContentCategory/Index.ascx
~/Areas/CMS/Views/Shared/Index.aspx
~/Areas/CMS/Views/Shared/Index.ascx
~/Views/ContentCategory/Index.aspx
~/Views/ContentCategory/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Areas/CMS/Views/ContentCategory/Index.cshtml
~/Areas/CMS/Views/ContentCategory/Index.vbhtml
~/Areas/CMS/Views/Shared/Index.cshtml
~/Areas/CMS/Views/Shared/Index.vbhtml
~/Views/ContentCategory/Index.cshtml
~/Views/ContentCategory/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
しかし~/Areas/CMS/Views/ContentCategory/Index.cshtml
、私のホストには存在します!
2) 他のいくつかのリクエストには、次のようなエラーがあるmysite.com/cms/content
か、次のmysite.com/cms/gallery
エラーがあります:
The partial view '~/Content/templates///views/Gallery/index.cshtml' was not found or no view engine supports the searched locations. The following locations were searched:
~/Content/templates///views/Gallery/index.cshtml
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The partial view '~/Content/templates///views/Gallery/index.cshtml' was not found or no view engine supports the searched locations. The following locations were searched:
~/Content/templates///views/Gallery/index.cshtml
Source Error:
Line 3: string view = "~/Content/templates/" + ViewBag.website + "/" + ViewBag.lang + "/views/Gallery/index.cshtml";
Line 4: Html.RenderPartial(view);
Line 5: }
Line 6:
このエラーの「ソース エラー」は、galleryController のデフォルト プロジェクト (cms ではない) ビューのコードを示しています。私はとても混乱しています。
繰り返しますが、これはホストとローカル システムで発生するだけで、すべてが正しいことを強調します。
また、このエラーは別のエラーの後に今日発生することにも注意してください。昨日、私のホストではすべてが修正され、このエラーは昨日までありませんでした!