How to achieve the same effict in asp.net core mvc like Server.Transfer in asp.net?

Xie Steven 811 Reputation points
2021-07-28T09:42:57.857+00:00

Hi,

Server.Transfer happens without the browser knowing anything, the browser request a page, but the server returns the content of another.

How to achieve the same target in asp.net core mvc?

Thanks

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,140 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 55,041 Reputation points
    2021-07-28T15:10:59.307+00:00

    Your action can just return another action.

    public ActionResult MyAction1(MyModel1 model)
    {
          // may need to create different model to pass
          return MyAction2(model);
    }
    

    Note: as the default view name is based on route parameters, MyAction2 should specify the view name rather than use default.

    0 comments No comments

0 additional answers

Sort by: Most helpful