how to redirect to aspx page in a controller action

后端 未结 2 1953
情深已故
情深已故 2020-12-17 14:55

is it possible to redirect to an aspx page in an (asp.net-mvc3 )controller action? What should be the return type of the action (ActionResult?) and which redirect method s

相关标签:
2条回答
  • 2020-12-17 15:03

    You can redirect to anywhere from MVC action and you have to use RedirectResult for that. RedirectResult is a type of ActionResult.

    For ex.

    public RedirectResult RedirectToAspx()
    {
      return Redirect("/pages/index.aspx");
    }
    
    0 讨论(0)
  • 2020-12-17 15:19

    Yes, just like razor.

    View:

    test.aspx
    

    Controller:

        public ActionResult test()
        {
            ViewBag.Message = "test。";
    
            return View();
        }
    
    0 讨论(0)
提交回复
热议问题