Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7514415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:29:23+00:00 2026-05-30T00:29:23+00:00

I have a page which open a new window with External Url (Twitter Authentication

  • 0

I have a page which open a new window with External Url (Twitter Authentication Url) now that window will authenticate the user and call back to an action method , in that action method i have to close the current window (popUp) and inform the opener that authentication succeeded,

in web forms i used to do something like this on a (postback):

            (HttpContext.Current.Handler as System.Web.UI.Page).ClientScript.RegisterStartupScript(
            this.GetType(),
            "winPop",
            "window.opener.doSomething(true);window.close()",
            true);

in MVC i tried this but didnt work since there is no Current but there is :

HttpContext.CurrentHandler

which can be casted to Mvc.MvcHandler now the question arise i know MVC is totally Different but is there is any way to register script which would run at the response startup ?

I know i can make an extra view and open it in the new window and then redirect to Twitter Url and then on the call back to the same Window i would call the script simply window.opener……etc but that would mean i have to make an extra view that only have nothing but a line of javascript at the startup, so i was wondering if i can do one of the following :

Option 1: Register Start up Script like i explained above.
Option 2: Return javascript code that runs at the client (no actual view).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:29:25+00:00Added an answer on May 30, 2026 at 12:29 am

    You can simply forget what you were doing classic WebForms as it won’t be of much of a help in ASP.NET MVC.

    In ASP.NET MVC you have Models, Controllers and Views (as its name suggests). So if you wanted to call a javascript function in your view and pass it some value from your model you could do the following:

    @model MyViewModel
    <script type="text/javascript">
        alert(@Html.Raw(Json.Encode(Model.SomeValue)));
    </script>
    

    where obviously your controller action will populate this model and pass it to the view:

    public ActionResult Foo()
    {
        var model = new MyViewModel
        {
            SomeValue = "Hello world"
        };
        return View(model);
    }
    

    and of course a corresponding model:

    public class MyViewModel
    {
        public string SomeValue { get; set; }
    }
    

    See? Model, View, Controller.


    UPDATE:

    in that action method i have to close the current window (popUp) and
    inform the opener that authentication succeeded,

    You don’t need a model in this simple case:

    public ActionResult CallbackAction()
    {
        return View();
    }
    

    and inside CallbackAction.cshtml:

    <script type="text/javascript">
        window.opener.doSomething(true);
        window.close();
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one page which enable user to choose something in a new window:
I have a page from which the user will be able to print .
Hey, on a page I have a link which opens up a new window
I've got a page which open a new window fullscreen but it still has
I have a page with several links that open a separate window with varying
I have an html page. On that page I want to open popup window.
I have an html page which has a link called open. Once the link
I have a web page which contains a select box. When I open a
I have defined a function in which i want to open a page on
I have page which is redirected from htaccess. now I can pass the German

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.