MVC Page not showing up, 404 not found
Posted
by mwright
on Stack Overflow
See other posts from Stack Overflow
or by mwright
Published on 2010-03-31T21:52:10Z
Indexed on
2010/03/31
22:03 UTC
Read the original article
Hit count: 406
I have a very simple MVC site that is returning a 404 not found error when trying to load a page at the very beginning. I'm looking for some direction to troubleshoot this problem since there is really nothing to go on from the error message.
The error I'm getting is:
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Views/Other/Index.aspx
Below I have included the code for the various pieces, routing rules are default:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults
);
The site is using nested MasterPages, not sure if this is involved with the problem but trying to include as much detail as possible.
I have:
Controllers
- OtherController
Views:
- Shared Folder:
- Site.Master
- Other Folder:
- Other.Master
- Index.aspx
Site.Master Code:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>
<asp:ContentPlaceHolder ID="TitleContent" runat="server" />
</title>
</head>
<body>
<div>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</body>
</html>
Other.Master Code:
<%@ Master Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewMasterPage" %>
<asp:Content ID="OtherTitle" ContentPlaceHolderID="TitleContent" runat="server">
OTHER PAGE - MASTER TITLE
<asp:ContentPlaceHolder ID="OtherPageTitle" runat="server">
</asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ID="OtherContent" ContentPlaceHolderID="MainContent" runat="server">
Some other content.
<asp:ContentPlaceHolder ID="PageContent" runat="server">
</asp:ContentPlaceHolder>
</asp:Content>
Index.aspx Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Other/Other.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="IndexTitle" ContentPlaceHolderID="OtherTitle" runat="server">
Home
</asp:Content>
<asp:Content ID="IndexContent" ContentPlaceHolderID="OtherContent" runat="server">
Index content
</asp:Content>
OtherController Code
namespace MVCProject.Controllers
{
public class OtherController : Controller
{
//
// GET: /Member/
public ActionResult Index()
{
// Have also tried:
// return View("Index", "Other.Master");
return View();
}
}
}
© Stack Overflow or respective owner