1

I am writing a tiny MVC app that is a utility to simulate the actions of getting an id from a portal and setting it in a database for another app to obtain while this app is open. I attempted to write it using ASP.NET MVC to "get my feet wet." In it, I am attempting to use the JavaScriptResult (DESPITE all the warnings) to execute Javascript's window.open function but I get only a file dialog that is acting like the FilePathResult - it displays a dialog box asking if I want to save my file which is the name of the ActionEResult. How do I do this?

public JavaScriptResult SessionTransferDesktop(string PortalUserId)
{
    /// .... Call Oracle SP to set token

    // Redirect to RON Scheduler
    string js = "window.open('/RONSchedulerMVC/default.aspx?p_token=' + portalToken);";
    // string js ="window.open('http://microsoft.com')";
    return JavaScript(js);
}
4
  • the dialog is labeled SessionTransferDesktop and it asks if I want to save or find a handler Commented Nov 3, 2010 at 21:06
  • Why aren't you just doing a Redirect and passing the token along? Commented Nov 3, 2010 at 21:10
  • OK I am trying Response.Redirect("/RONSchedulerMVC/default.aspx?p_token=" + portalToken); RONSchedulerMVC is another project in the same solution but it isn't working. How do I specify the URL? Commented Nov 3, 2010 at 21:21
  • Ok, tried Response.Redirect(localhost/RONSchedulerMVC... Commented Nov 3, 2010 at 21:36

2 Answers 2

1
public ActionResult SessionTransferDesktop(string PortalUserId)
{
    /// .... Call Oracle SP to set token

    // build url and redirect
    var uriBuilder = new UriBuilder("http://example.com");
    uriBuilder.Path = "/RONSchedulerMVC/default.aspx";
    uriBuilder.Query = "p_token=" + Url.Encode(portalToken);
    return Redirect(uriBuilder.ToString());
}
Sign up to request clarification or add additional context in comments.

6 Comments

This is getting to the application which is running in Cassini and producing "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS."
The other guy switched over the app to IIS but we can't get the default.aspx to run there.
HttpContext.Current.RewritePath(Request.ApplicationPath, false); IHttpHandler httpHandler = new MvcHttpHandler(); httpHandler.ProcessRequest(HttpContext.Current);
It is IIS 5.1 we have. Does MVC run on IIS 5.1?
HttpContext.Current.RewritePath(Request.ApplicationPath, false); is "/" in Casini and "/RonSchedulerMVC/" in IIS but we can't get it to run in IIS 5.1
|
0

You are getting the file result because your browser is requesting something and getting content-type:application/javascript back.

The easiest way to get this to work is to simply make the route redirect the response to the portal. You can then just call window.open directly on said route and profit.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.