So on my MVC site, I need to open a dynamically generated URL in a new tab. What I've got for code so far is below:
<a class='noline' onclick="location.href='<%:@Url.Action("GeneratePaymentUrl", "Home", new {target="_blank"})%>'"> Pay Invoices</a>
public ActionResult GeneratePaymentUrl()
{
try
{
string returl = GetPaymentUrl();
if (returl.ToLower().StartsWith("http"))
{
//Response.Redirect(returl);
return new RedirectResult(returl, false);
}
else
{
return new RedirectResult("/");
}
}
catch (Exception Ex)
{
}
return new RedirectResult("/");
}
Now, the URL has to be generated when the link as clicked; as it will go to an external payment gateway and the authorization time is extremely short-lived. Right now the code works; where it will open up the page correctly, but not in a new tab. If i try adding in target="blank" href="/"
to the anchor tag; i end up getting the landing page in a new window and the payment gateway in the original.
How can i get this to pop in a new window?