我正确链接了导航栏项目,但是它们无法正常工作

时间:2018-12-11 11:31:20

标签: c# model-view-controller

我是MVC的新手,有一个问题。基本上,我有2个控制器。Home控制器和Film控制器。我使用导航栏作为布局。home控制器的所有操作方法都在nav-bar中调用。当我单击导航栏项目时,它很完美,但是当我使用胶片控制器,然后单击导航栏项目时,URL更改如/ Film / .....但应为/ Home /....

这是我的家庭控制器:

 public class HomeController : Controller
{
    // GET: Home
    public ActionResult Index()
    {

        return View();
    }       
    public ActionResult Vizyondakiler()
    {
        return View();
    }
    public ActionResult Giris()
    {

        return View();
    }
    public ActionResult Filmler()
    {
        Model1 db = new Model1();
        var res = db.Table_Filmler.OrderByDescending(x => x.puan).Take(3).ToList();
        return View(res);           
    }


}

这是我的电影控制器:

public class FilmController : Controller
{            
    public ActionResult Goruntule(int id)
    {
        Model1 db = new Model1();
        var film = db.Table_Filmler.Where(x => x.filmId == id).ToList();
        var oyuncular = db.tbl_oyuncular.Where(x => x.filmId == id).ToList();
        ViewData["oyuncular"] = oyuncular;
        return View(film);
    }
}

这是我的导航栏:

<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
    <div class="container">
        @Html.ActionLink("Film Arşivi", "Index", "Home", new { @class = "navbar-brand" })    
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item">                   
                     @Html.ActionLink("Anasayfa", "Index", "Home", new { @class = "nav-link" })                    
                </li>
                <li class="nav-item">                   
                     @Html.ActionLink("Filmler", "Filmler", "Home",new { @class = "nav-link"})
                </li>
                <li class="nav-item">
                    @Html.ActionLink("Vizyondakiler", "Vizyondakiler", "Home", new { @class = "nav-link" })
                </li>
                <li class="nav-item">
                    @Html.ActionLink("Giris", "Giris", "Home", new { @class = "nav-link" })
                </li>
            </ul>
        </div>
    </div>
</nav>

我在这里给电影控制器打电话

 <div class="caption">
                <h5>@item.isim (@item.yıl)</h5>
                <p>@(item.acıklama.Substring(0,47) + "...")</p>
                <p>
                    @Html.ActionLink("Görüntüle", "Goruntule", "Film",new {id = item.filmId,},new { @type = "button",@class = "btn btn-primary" })

                    <a href="#" class="btn btn-secondary" role="button">+İzleme Listesine Ekle</a>
                </p>

0 个答案:

没有答案