从Asp.net MVC4控制器调用不同文件夹的视图 [英] Calling View of different folder from Asp.net mvc4 controller

查看:316
本文介绍了从Asp.net MVC4控制器调用不同文件夹的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在View的Jobs文件夹中有一个View名称"Message".我想返回该视图的形式是另一个控制器的操作,该控制器名为"MarketController"

I hava a View Name "Message" in the Jobs folder of Views. And I want to return that view form an action of different controller, named "MarketController"

 public class MarketController : Controller
    {

      [HttpPost]
      public ActionResult Save()
        {
          // logic to save the record
            TempData["message"] = "Save successfully";
            return View("Message");   
        }
   }  

问题是消息"视图不在市场视图中,我如何从MarketController返回该视图.
(我不想在这里使用RedirectToaction方法.)

The problem is that the "Message" view is not in the View of Market, how can i return that view from MarketController.
(I do not want to use RedirectToaction method here.)

推荐答案

只需使用基于Views文件夹的相对路径

Just use a relative path based on the Views folder

return View("~/Views/Jobs/Message.cshtml");   

这篇关于从Asp.net MVC4控制器调用不同文件夹的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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