Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 17, 2012 02:25 AM by bkis1112
Member
23 Points
41 Posts
May 16, 2012 04:27 PM|LINK
In your layout page in the head section add this
@RenderSection("metas", true)
This will Render a "Section" found in the view called "metas", the true part tells the RenderSection method that the section *is* required.
You can make that decision for yourself though.
Then in each view you want to define a set of meta tags for you define a section as follows
@section metas { <meta name="description" content="Page Description Here..."> <meta name="keywords" content="Keywords Here...."> }
Participant
1061 Points
226 Posts
May 17, 2012 02:25 AM|LINK
in your _layout:
<title>@ViewBag.Title</title> <meta name="description" content="@ViewBag.Description" /> <meta name="keywords" content="@ViewBag.Keywords" />
in your view
@{ ViewBag.Title = ViewData["title"].ToString(); ViewBag.Keywords = ViewData["keywords"].ToString(); ViewBag.Description = ViewData["description"].ToString(); Layout = "~/Views/Shared/_Layout.cshtml"; }
let me know if you get any issue
ntek designs
Member
23 Points
41 Posts
Re: Seach engine optimized
May 16, 2012 04:27 PM|LINK
In your layout page in the head section add this
@RenderSection("metas", true)
This will Render a "Section" found in the view called "metas", the true part tells the RenderSection method that the section *is* required.
You can make that decision for yourself though.
Then in each view you want to define a set of meta tags for you define a section as follows
@section metas { <meta name="description" content="Page Description Here..."> <meta name="keywords" content="Keywords Here...."> }bkis1112
Participant
1061 Points
226 Posts
Re: Seach engine optimized
May 17, 2012 02:25 AM|LINK
in your _layout:
<title>@ViewBag.Title</title> <meta name="description" content="@ViewBag.Description" /> <meta name="keywords" content="@ViewBag.Keywords" />in your view
@{ ViewBag.Title = ViewData["title"].ToString(); ViewBag.Keywords = ViewData["keywords"].ToString(); ViewBag.Description = ViewData["description"].ToString(); Layout = "~/Views/Shared/_Layout.cshtml"; }let me know if you get any issue
Trần Lê Thành Trung