ArmorCode
ArmorCode

Reputation: 749

Unable to find _Layout in page inspector mode

I'm writing a simple MVC4 application in which I chose the internet application template when I created the project. When I right click _Layout.cshtml and go to view in page inspector, I receive a screen in the page inspector view that says

"Server Error in '/' Application.

The resource cannot be found. 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: /Shared/_Layout


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034

However, the _layout.cshtml shows up fine when launching debug mode for the solution. Also, the other cshtml pages are showing up fine in page inspector mode.

Views/_ViewStart.cshtml

Browse to URL property: ~/Views/_ViewStart.cshtml

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

Views/Shared/_Layout.cshtml

Browse to URL property: ~/Views/Shared/_Layout

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - Movie App</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    </head>
    <body>
        <header>
            <div class="content-wrapper">
                <div class="float-left">
                    <p class="site-title">@Html.ActionLink("MVC Movie", "Index", "Home")</p>
                </div>
                <div class="float-right">
                    <section id="login">
                        @Html.Partial("_LoginPartial")
                    </section>
                    <nav>
                        <ul id="menu">
                            <li>@Html.ActionLink("Home", "Index", "Home")</li>
                            <li>@Html.ActionLink("About", "About", "Home")</li>
                            <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        <footer>
            <div class="content-wrapper">
                <div class="float-left">
                    <p>&copy; @DateTime.Now.Year - My ASP.NET MVC Application</p>
                </div>
            </div>
        </footer>

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>

If you need more information to help solve this problem, please ask and I'll post it.

Upvotes: 1

Views: 1114

Answers (2)

Danny
Danny

Reputation: 936

I also could not open .cshtml files. Maybe page inspector is not supposed to do that. I think it is supposed to load the website in your local host the same way a browser would. Instead of trying to open the .cshtml file, try opening the website by opening the namespace/assembly name. When I do that page inspector works.

I also did some other things beforehand which may have helped. I read them here.

"I am getting this same error, and I tried to apply the proposed solution above. I still get the error after. And while I am using a 64-bit machine, I went on to try the same solution in the ...\Framework...\ folder. After editing and saving, the problem went away.

/***

Open your root web.config, (in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config) and comment (change 'add' to 'remove') this line referencing the assembly:

***/

PrfyVdlx"

Upvotes: 0

CM Kanode
CM Kanode

Reputation: 1436

Okay, I still stand by my comment that it is not meant to view the layout file as a standalone piece. However, I was a little curious as to the issue of viewing the layout.

If you look at the provided link, you will see how to properly use the Page Inspector. Please look at item number 5. That will give you some details on how to view pieces of your _layout file.

http://www.asp.net/mvc/tutorials/mvc-4/using-page-inspector-in-aspnet-mvc

Upvotes: 2

Related Questions