c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
asp.net MVC

If page = 'home' then display content for asp.net MVC project

| | ASP-NET , MVC

In this tutorial I will show you if it is home page then display content in asp.net MVC.
STEP 1: Create a partial view "_slider.cshtml"

<!--Carousel Wrapper-->

<div id="carousel-example-2" class="carousel slide carousel-fade mb-5" data-ride="carousel">
<!--Indicators-->
<ol class="carousel-indicators">
<li data-target="#carousel-example-2" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-2" data-slide-to="1"></li>
<li data-target="#carousel-example-2" data-slide-to="2"></li>
</ol>
<!--/.Indicators-->
<!--Slides-->
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="view hm-white-slight">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(147).jpg" alt="First slide">
<div class="mask"></div>
</div>
<div class="carousel-caption">
<h3 class="h3-responsive">First title</h3>
<p>First text</p>
</div>
</div>
<div class="carousel-item">
<!--Mask color-->
<div class="view hm-white-slight">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(151).jpg" alt="Second slide">
<div class="mask"></div>
</div>
<div class="carousel-caption">
<h3 class="h3-responsive">Second title</h3>
<p>Second text</p>
</div>
</div>
<div class="carousel-item">
<!--Mask color-->
<div class="view hm-white-slight">
<img class="d-block w-100" src="https://mdbootstrap.com/img/Photos/Slides/img%20(152).jpg" alt="Third slide">
<div class="mask"></div>
</div>
<div class="carousel-caption">
<h3 class="h3-responsive">Third title</h3>
<p>Third text</p>
</div>
</div>
</div>
<!--/.Slides-->
<!--Controls-->
<a class="carousel-control-prev" href="#carousel-example-2" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel-example-2" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
</div>
<!--/.Carousel Wrapper-->

STEP 2: In home controller, create a ViewBag property isHome and set true.


 public ActionResult Index(int? page)

{
ViewBag.isHome = true;

models db = new models();
var courses = (from video in db.Courses
orderby video.CourseId descending
select video);
int maxRows = 10;
int pageNumber = (page ?? 1);
return View(courses.ToPagedList(pageNumber, maxRows)); }

STEP 3:_Layout.cshtml

@if (ViewBag.isHome != null)

{

if (ViewBag.isHome)
{
@Html.Partial("_Slider") } }


VIDEO GUIDE: