Reputation: 13855
Form -> Submit
Takes you to view of the new entry.
How can I open a new tab that sends you to a new actionresult return File(document, mimeType);
while still directing you on the main tab?
I'm at a loss, I cant open a new tab via ASP.NET Code, nor invoke two different actionresults.
Upvotes: 1
Views: 661
Reputation: 4413
You would need to do it client side. You have 2 options:
1) A shell page that has nothing except for the following javascript:
$(document).ready(function() {
window.open("@Model.DownloadUrl", "");
window.location.href = "@Model.RedirectUrl";
});
2) Modifying the view to check for a DownloadUrl
via javascript and download it if available:
$(document).ready(function() {
if (@!string.IsNullOrEmpty(Model.DownloadUrl)) {
window.open("@Model.DownloadUrl", "");
}
});
In either case, there's no way to force the new window to be opened as a new tab. That's a user's browser setting. The javascript above opens a new tab in the version of Chrome and Firefox I have but not in IE.
Upvotes: 1
Reputation: 11964
Your problem should be solved on the client side, not only on the server. Maybe I misunderstood something, but if you want to open a new browser tab, you just need to place a <a href="@Html.Action("SomeAction")" target="_blank">
(Razor syntax) in your main tab.
Upvotes: 2