Solved

mvc redirect question

Posted on 2014-08-01
4
403 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

939 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

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now