Razor RenderSection doesn't work -


i'm experienced web developer who's been doing project management instead of development year, i'm trying jump , learn razor. far, it's been dismal failure.

i created new empty razor web site in vs2012, , created following files:

_mainlayout.cshtml:

<!doctype html> <html>     <head>         <title>razor test</title>     </head>     <body>         <div>@renderbody()</div>         <div>@rendersection("testsection")</div>     </body> </html> 

contentpage1.cshtml:

@{     layout = "_mainlayout.cshtml"; }  <div>this content on razor test page.</div> 

and testsection.cshtml:

@{     layout = "_mainlayout.cshtml";  }  @section testsection {     <h1>this test section</h1> } 

when try , run page, following error:

section not defined: "testsection".

and idea what's happening? supposed ridiculously simple it. apparently it's too simple.

sections should go inside page not in separate cshtml

contentpage1.cshtml:

@{     layout = "_mainlayout.cshtml"; } @section testsection {     <h1>this test section</h1> }  <div>this content on razor test page.</div> 

or if want separate cshtml "section like" display use partial views instead.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -