简体   繁体   English

找不到资源MVC4

[英]The resource cannot be found MVC4

I have uploaded my site on server. 我已将网站上传到服务器上。 And there is an error occurred. 并且发生了错误。 My site url is http://vintageoverseas.org/ . 我的网站网址是http://vintageoverseas.org/ Here is a page that's url is http://vintageoverseas.org/en/Blog but when i click on read more button Blog title then The resource cannot be found. 这是URL为http://vintageoverseas.org/en/Blog的页面,但是当我单击“ read more按钮Blog title The resource cannot be found. In this action name is BlogPost and when i change it to Post than this error is occurred as 在此操作中,名称为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 

And my controller name is Home and it's code is 我的控制器名称是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);
        }

And view name is BlogPost 并且视图名称是BlogPost

And routing is 路由是

 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 }
            ); 
        }

Are you sure your BlogPost action resides in HomeController.cs? 您确定您的BlogPost操作驻留在HomeController.cs中吗? Or is there a controller named "en"? 还是有一个名为“ en”的控制器?

You might need a {controller} parameter in your first route, and then modify your anchor to utilize controller as @Html.ActionLink("Read More...", "BlogPost", "ControllerName", new {id="123", null); 您可能在第一个路径中需要一个{controller}参数,然后修改锚点以将控制器用作@Html.ActionLink("Read More...", "BlogPost", "ControllerName", new {id="123", null);

Try using route debugger - it can be turned on and off using a web.config switch after installed: https://www.nuget.org/packages/routedebugger 尝试使用路由调试器-安装后可以使用web.config开关将其打开和关闭: https : //www.nuget.org/packages/routedebugger

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM