如何使用单个控制器访问多个视图 [英] How Do I Access Multiple Views Using A Single Controller

查看:59
本文介绍了如何使用单个控制器访问多个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!我是asp.net mvc的新手,我做了一个控制器名称库,查看名称索引,我还在图库控制器内做了另一个视图名称图库,在索引视图中我做了一个像文件夹一样的按钮,当我点击那个按钮我去画廊图片视图,但是当我点击它时有问题资源无法找到。这是我的图库视图代码

Hi! i'm new in asp.net mvc, i made a controller name gallery, view name index, i also made a another view name picture gallery inside the gallery controller, In index view i made a button like folder , when i click that button i go to the gallery picture view, but there is problem when i click it says Resource cannot be found. Here is my code of gallery view

<div class="container" style="padding:100px">
    <div class="row">
     <div class="col-lg-9">
<a href="@Url.Action("PictureGallery", "Gallery")" class="btn btn-primary" style="width:200px; height:200px"></a>
</div>
</div>
</div>



这是我的控制器代码


here is my controller code

public class GalleryController : Controller
    {
      
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult PictureGallery()
        {
            return View();
        }

推荐答案

你应该有一个视图命名为PictureGallery,因为你已经为它创建了动作方法。

你可以右键单击该方法,然后选择添加视图。



从那里,您可以为该方法创建一个视图。



-KR
You should have a view named as PictureGallery, as you've created action method for that.
You can right click on that method, and choose Add View.

From there, you can create a view for that method.

-KR


这篇关于如何使用单个控制器访问多个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆