Link to home
Start Free TrialLog in
Avatar of Dinesh Kumar
Dinesh KumarFlag for India

asked on

mvc redirect question

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
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

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

?
ASKER CERTIFIED SOLUTION
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dinesh Kumar

ASKER

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();        
    }
Thanks for sharing!