I am using route attributes with areas.
My route config is :
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" }
);
}
On my local every things is correct! Today when I published my project and upload its on my host I faced with tow types of errors.
If I request url of Default MapRoute like mysite.com/Contents/1060
everything is correct! But when I request a url of my area, I faced tow type of errors!
1) some requests like mysite.com/cms/comment
or mysite.com/cms/category
has this error:
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.
but ~/Areas/CMS/Views/ContentCategory/Index.cshtml
is exist on my host!
2) some other requests like mysite.com/cms/content
or mysite.com/cms/gallery
has this error:
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:
The 'Source Error' of this error show some code of my default project(not cms) view of galleryController! I am so confused.
I emphasize again this just happen on host and on my local system every things is correct!
It should also be noted that this error happen today after another error, yesterday on my host everything was corrected and this error was not until yesterday!