[英]The resource cannot be found MVC4
我已将网站上传到服务器上。 并且发生了错误。 我的网站网址是http://vintageoverseas.org/ 。 这是URL为http://vintageoverseas.org/en/Blog的页面,但是当我单击“ read more
按钮Blog title
The resource cannot be found.
在此操作中,名称为BlogPost
,当我将其更改为Post
时,将发生以下错误:
The view 'Post' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Post.aspx
~/Views/Home/Post.ascx
~/Views/Shared/Post.aspx
~/Views/Shared/Post.ascx
~/Views/Home/Post.cshtml
~/Views/Home/Post.vbhtml
~/Views/Shared/Post.cshtml
~/Views/Shared/Post.vbhtml
我的控制器名称是Home
,其代码是
public ActionResult BlogPost(long? Id)
{
BlogModel blog = new BlogModel();
blog = b.GetBlogDetail(Id.ToString());
List<TagModel> tags = new List<TagModel>();
tags = b.GetBlogTags(blog.blog_id.ToString());
blog.tag_name_list = tags.Select(m => m.tag_name).ToList();
List<ImageModel> image = new List<ImageModel>();
image = b.GetBlogImages(blog.blog_id.ToString());
blog.img_path_list = image.Select(m => m.path).ToList();
blog.parent_cat_id = b.GetMainParent(blog.cat_id);
return View(blog);
}
并且视图名称是BlogPost
路由是
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Custom",
url: "en/{action}/{id}/{Title}",
defaults: new { controller = "Home", action = "Index",
id = UrlParameter.Optional, Title = UrlParameter.Optional, en = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
您确定您的BlogPost操作驻留在HomeController.cs中吗? 还是有一个名为“ en”的控制器?
您可能在第一个路径中需要一个{controller}
参数,然后修改锚点以将控制器用作@Html.ActionLink("Read More...", "BlogPost", "ControllerName", new {id="123", null);
尝试使用路由调试器-安装后可以使用web.config开关将其打开和关闭: https : //www.nuget.org/packages/routedebugger
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.