简体   繁体   English

ASP.NET MVC 4-返回主控制器视图

[英]ASP.NET MVC 4 - return to home controller view

I am using ASP.NET MVC 4 and I have the home controller with a view and I created an API Controller, what I am trying to do is at the end of my method in my API Controller, to return the user to home controller view. 我正在使用ASP.NET MVC 4,并且具有带有视图的主控制器,并且创建了一个API控制器,我想做的是在我的API控制器中方法的最后,将用户返回到主控制器视图。 How would I do this? 我该怎么做?

HomeController 家庭控制器

namespace ASPNETMVC4_Tutorial.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    }
}

My Api Controller 我的Api控制器

namespace ASPNETMVC4_Tutorial.Controllers
{
    public class PersonController : ApiController
    {
        [HttpPost]
        public dynamic Post([FromBody]PersonsClass person)
        {
            person.insertPerson(person);
            return true;
        }
    }
}

Please Help. 请帮忙。

The api controller is not on charge of handling navigation, it should be client technology agnostic. api控制器不负责处理导航,它应该与客户端技术无关。 This means, if the api is well designed and implemented, that you could use it on a mobile application, a web application or any other application type that can use the http protocol. 这意味着,如果api设计和实现良好,则可以在移动应用程序,Web应用程序或可以使用http协议的任何其他应用程序类型上使用它。

Url navigation is web specific and that's why can't be there. 网址导航特定于网络,这就是为什么不能在那里。 The correct place to do it on your case would be on succeed handler on javascript side. 在您的情况下,执行此操作的正确位置将在javascript端的succeed处理程序上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM