Solved

mvc redirect question

Posted on 2014-08-01
4
416 Views
Last Modified: 2014-08-02
Hi Experts,

Please see below code:

HTML
<input type="button" id="btnManage" value="ManageActivation" onclick="Test()" />


  function Test() {
        debugger;
        location.href = "/Home/GetTest";
    }

Open in new window


MVC:
 public ActionResult GetTest()
        {
  string url = "window.open('http://www.google.com','_blank');";
  return new RedirectResult(url, false);
}

Open in new window



but it goes to http://localhost:33419/Home/window.open('http://www.google.com','_blank');
and it says HTTP Error 404.0 - Not Found

I want to open google.com in new tab.

return Redirect(url); is also not working.

thanks
meetDinesh
0
Comment
Question by:Dinesh Kumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40234149
Is there any reason why you're not simply doing:
<input type="button" id="btnManage" value="ManageActivation" onclick="Test()" />
  function Test() {
        debugger;
        window.open('http://www.google.com','_blank');
    }

Open in new window

?
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 40234339
I think the URL is supposed to be variable.

Have you tried:

'javascript:window.open('http://www.google.com','_blank')'

?
0
 

Author Closing Comment

by:Dinesh Kumar
ID: 40236186
Thank you.

  public ActionResult MA(MA inputs)
        {

               return Content(script); //script contains window.open('..  like string.
       }  

 var callBackFunction = function (result) {
        var tmpFunc = new Function(result);         //also avoided eval
        tmpFunc();        
    }
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 40236299
Thanks for sharing!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Run tasks synchronously in background thread 19 81
PowerShell:  foreach where object notmatch? 17 76
How does this modal work? 3 33
Datagridview column resizing 8 25
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question