Search code examples
asp.netasp.net-mvcasp.net-mvc-5

How do I fix homepage issue in MVC 5 when i add bootsrap lumen theme?


Please help with this as I want to customize the navbar and replace the names from default such as application and index etc to my application, home page and etc. image of a webpage after adding bootstrap lumen theme no nav bar and no proper content displayed Model Page Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace VidlyMovies.Models
{
public class Customers
{
public int Id  { get; set; }
public string Name { get; set; }
}
}

LayoutpageCode

 @{
    ViewBag.Title = "Random";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2> @Model.Movies.Name</h2> 

Controller Page Code

namespace VidlyMovies.Controllers
{
public class MoviesController : Controller
{
// GET: Movies/Random 
public ActionResult Random()
{
 var movie = new Movies() {Name = "Avengers"};
 return View(movie);
}
}
}

Solution

  • OK, assuming this is Bootstrap 3 and your "css" bundle is loading it, their example here could be used. Taking a shot at integrating your code I would try:

    <body>
      <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <!-- Wrap your banner, app name etc. in a link back to home page -->
                <a href="@Url.Action("Vidly", "Home", new { area = "" })" class="navbar-brand" title="Return to home page.">
                    <!-- I am using a font awesome icon plus text. You can use a bootstrap glyph or a banner, image, etc. -->
                    <span><i class="fa fa-home"></i> My App Name</span>
                </a>
            </div>
            <!-- This is where you put your menu items. It will collapse if screen is small. The id is important to link above. -->
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li class="active">@Html.ActionLink("Vidly", "Vidly", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                </ul>
            </div>
        </div>
      </nav>
      <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
      </div>
      @Scripts.Render("~/bundles/jquery")
      @Scripts.Render("~/bundles/bootstrap")
      @RenderSection("scripts", required: false)
    </body>