Calling View of different folder from Asp.net mvc4 controller

前端 未结 2 937
陌清茗
陌清茗 2021-01-03 23:28

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\"



        
相关标签:
2条回答
  • 2021-01-04 00:15

    You have to fill the full address for your Message view ("~/Views/Jobs/Message.cshtml"):

    [HttpPost]
    public ActionResult Save()
    {
        TempData["message"] = "Save successfully";
        return View("~/Views/Jobs/Message.cshtml");
    }
    
    0 讨论(0)
  • 2021-01-04 00:17

    Just use a relative path based on the Views folder

    return View("~/Views/Jobs/Message.cshtml");   
    
    0 讨论(0)
提交回复
热议问题