TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rahul Patil
1.5k
183
31.1k
How to access a view in layout.cshtml in mvc??
Dec 23 2019 7:08 AM
I m working with MVC I m newbie in mvc.
when I m accessing an individual view then give an error: Additional information: Section not defined: "ContactUs".
HomeController:
public
class
HomeController : Controller
{
// GET: Home
public
ActionResult Index()
//main content
{
return
View();
}
public
ActionResult ContactUs()
{
return
View();
}
}
Index.cshtml
@{
ViewBag.Title =
"Index"
;
}
Index
This
is
main body means Dynamic Content
layout.cshtml
"utf-8"
/>
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
@ViewBag.Title - Template Editing
"~/Content/Site.css"
rel=
"stylesheet"
type=
"text/css"
/>
"~/Content/bootstrap.min.css"
rel=
"stylesheet"
type=
"text/css"
/>
<!-- Inject Script Filtered -->
class
=
"container body-content"
>
Good Template
@RenderBody()
@RenderSection(
"ContactUs"
) //here get an error
Additional information: Section not defined: "ContactUs".
2016@CopyRightsReserved
<!-- Inject Script Filtered -->
<!-- Inject Script Filtered -->
ContactUs.cshtml
@{
ViewBag.Title =
"ContactUs"
;
}
ContactUs
hello
this
is
good guy Contact This Person
when I m accessing a contact.cshtml then error shown section is not defined??
Reply
Answers (
4
)
Getting Data From WebAPI
How to develop asp core shopping cart