Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

ASp.net question

  • 07-07-2012 1:24pm
    #1
    Closed Accounts Posts: 18,268 ✭✭✭✭


    I am getting the following error when I am creating a new view in my application.
    Has anyone any ideas what's going on with it?

    thanks in advance.


    Server Error in '/' Application.

    The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Scripts".

    [FONT=Arial, Helvetica, Geneva, SunSans-Regular, sans-serif] 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.Web.HttpException: The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Scripts".

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:

    [HttpException (0x80004005): The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_Layout.cshtml": "Scripts".] System.Web.WebPages.WebPageBase.VerifyRenderedBodyOrSections() +205359 System.Web.WebPages.WebPageBase.PopContext() +316 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +95 System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +233 System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10 System.Web.WebPages.WebPageBase.Write(HelperResult result) +71 System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +64 System.Web.WebPages.WebPageBase.PopContext() +246 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +95 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +260 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +295 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242 System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177 System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +89 System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43 System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__4(IAsyncResult asyncResult) +25 System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48 System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9637232 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 [/FONT]


Comments

  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Do you have a required section defined in the layout page that you aren't specifying in the sub view?


  • Closed Accounts Posts: 18,268 ✭✭✭✭uck51js9zml2yt


    An honest answer..I dont know!

    Its a bit of developing on the fly here. My lecturer had a look and didn't have any solution to it.

    I'm going to give creating a Master Site file a go over the weekend which will hopefully bypass the problem.


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Have a look in the _layout.cshtml file in the Shared folder, is there a piece of code similar to the following
    @RenderSection("SomeName", true)
    

    If there is, change the true to false, or leave it true, and do the following in your new view
    @section SomeName {
    <h1>Hello</h1>
    }
    


  • Registered Users, Registered Users 2 Posts: 1,266 ✭✭✭Overflow


    An honest answer..I dont know!

    Its a bit of developing on the fly here. My lecturer had a look and didn't have any solution to it.

    I'm going to give creating a Master Site file a go over the weekend which will hopefully bypass the problem.

    I suggest you read upi about Razor view before just diving in and getting stuck on problems like this:

    http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx


  • Closed Accounts Posts: 18,268 ✭✭✭✭uck51js9zml2yt


    Giblet wrote: »
    Have a look in the _layout.cshtml file in the Shared folder, is there a piece of code similar to the following
    @RenderSection("SomeName", true)
    
    If there is, change the true to false, or leave it true, and do the following in your new view
    @section SomeName {
    <h1>Hello</h1>
    }
    

    We realised after posting that the _layout is the site master in MVC4.

    This is the code in _layout.cshtml. I dont see a true/false

    <!DOCTYPE html>
    <html>
    <head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    </head>
    <body>
    <div class="page">
    <div id="header">
    <div id="title">
    <h1>Rate My Amenity</h1>
    </div>

    <div id="logindisplay">
    @Html.Partial("_LoginPartial")
    </div>
    <div id="menucontainer">
    <ul id="menu">
    <li>@Html.ActionLink("Home", "Index", "Home")</li>
    <li>@Html.ActionLink("About", "About", "Home")</li>
    <li>@Html.ActionLink("Users", "Index", "User")</li>
    <li>@Html.ActionLink("Ratings", "Index", "Rating")</li>
    <li>@Html.ActionLink("Amenities", "Index", "Amenity")</li>
    </ul>
    </div>
    </div>
    <div id="body">
    @RenderBody()
    </div>
    <div id="footer">
    </div>
    </div>
    </body>
    </html>


  • Advertisement
  • Site Banned Posts: 153 ✭✭kegzmc


    Are you sure this is C#? Looks more like ASP to me.

    Keggles


  • Closed Accounts Posts: 18,268 ✭✭✭✭uck51js9zml2yt


    kegzmc wrote: »
    Are you sure this is C#? Looks more like ASP to me.

    Keggles

    look at the title of my question.
    Its asp using c#


  • Registered Users, Registered Users 2 Posts: 11,989 ✭✭✭✭Giblet


    Look in the _LoginPartial view as well.


  • Registered Users, Registered Users 2 Posts: 1,266 ✭✭✭Overflow


    We realised after posting that the _layout is the site master in MVC4.

    This is the code in _layout.cshtml. I dont see a true/false

    <!DOCTYPE html>
    <html>
    <head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    </head>
    <body>
    <div class="page">
    <div id="header">
    <div id="title">
    <h1>Rate My Amenity</h1>
    </div>

    <div id="logindisplay">
    @Html.Partial("_LoginPartial")
    </div>
    <div id="menucontainer">
    <ul id="menu">
    <li>@Html.ActionLink("Home", "Index", "Home")</li>
    <li>@Html.ActionLink("About", "About", "Home")</li>
    <li>@Html.ActionLink("Users", "Index", "User")</li>
    <li>@Html.ActionLink("Ratings", "Index", "Rating")</li>
    <li>@Html.ActionLink("Amenities", "Index", "Amenity")</li>
    </ul>
    </div>
    </div>
    <div id="body">
    @RenderBody()
    </div>
    <div id="footer">
    </div>
    </div>
    </body>
    </html>

    Ok do you have the code for the Index.cshtml view file ?

    I suspect you have something like this in your Index view:

    [PHP]
    section Scripts{

    }
    [/PHP]
    You need to remove this as it is not defined in your Layout.cshtml file.

    You define these sections in your layout with:

    [PHP]
    RenderSection("SomeName", false);
    [/PHP]

    Then is views that use this layout. You can insert content into these sections by using:

    [PHP]
    section SomeName{
    <!-- insert html content here -->
    }
    [/PHP]


  • Closed Accounts Posts: 18,268 ✭✭✭✭uck51js9zml2yt


    We got it sorted. thanks for all the help.

    It was all down to a data string having been changed in the web config file.


  • Advertisement
Advertisement