Redirect to a hash from the controller using “RedirectToAction”

前端 未结 4 1297
不知归路
不知归路 2020-11-29 22:41

Hello I want to return an anchor from Mvc Controller

Controller name= DefaultController;

public ActionResult MyAction(int id)
{
        return Redi         


        
4条回答
  •  离开以前
    2020-11-29 23:26

    To Expand on Squall's answer: Using string interpolation makes for cleaner code. It also works for actions on different controllers.

    return Redirect($"{Url.RouteUrl(new { controller = "MyController", action = "Index" })}#anchor");
    

提交回复
热议问题