Prabhat-VS
Prabhat-VS

Reputation: 1530

How to open new window from MVC using RedirectToAction?

I want to open View throe controller using RedirectToAction, how to open new window?

public async Task<ActionResult> RepINVPurchaseAbstract(PAbstract ObjPAbs, string ButtonValue)
            {    
             return RedirectToAction("ReportDisplay", "Common", new { area = "" });
           }

Any help would be appriciated.

Upvotes: 1

Views: 3154

Answers (2)

SᴇM
SᴇM

Reputation: 7213

Lets assume your link or button or whatever looks like this:

@Html.ActionLink("ActionName", "Controller")

add target="_blank" to you to open it in new tab or window (depending on what browser you use and what browser configurations are set):

@Html.ActionLink("RepINVPurchaseAbstract", "YourController", null, new { target = "_blank" })

It will redirect to your RepINVPurchaseAbstract action method then will redirect to your "ReportDisplay" action and will render out your view.

Upvotes: 1

Fka
Fka

Reputation: 6234

It is impossible to return a result of a action to a new window, as the action was called from origin one and origin one waits for response. What I would do, is open a new window first, with specific parameters (either in URL or in JavaScript event body.onload that perform your action and return result directly to new window.

Upvotes: 1

Related Questions