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 7518333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:44:08+00:00 2026-05-30T01:44:08+00:00

I want to get Network Interface on which HttpWebRequest was made I found WebRequestExtensions.GetCurrentNetworkInterface

  • 0

I want to get Network Interface on which HttpWebRequest was made

I found WebRequestExtensions.GetCurrentNetworkInterface function for this. HttpWebRequest also has GetCurrentNetworkInterface() method to perform the same.

This is my code:

 HttpWebRequest httpWebRequest = HttpWebRequest.CreateHttp(new Uri(Url, UriKind.Absolute)); 
 //this line throws InvalidOperationException       
 NetworkInterfaceInfo i = httpWebRequest.GetCurrentNetworkInterface();

I perform method call from UI thread. If I made call after BeginGetResponse exception tells “request was finished”. What is workaround for this?

Exception info:

Message is InvalidOperationException

StackTrace:

  at System.Net.Browser.ClientHttpWebRequest.GetConnectionDetails(IntPtr& Details, Int32& sizeofDetails)
  at Microsoft.Phone.Net.NetworkInformation.WebRequestExtensions.GetCurrentNetworkInterface(WebRequest request)
  • 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-30T01:44:09+00:00Added an answer on May 30, 2026 at 1:44 am
    HttpWebRequest httpWebRequest = HttpWebRequest.CreateHttp(new Uri(Url, UriKind.Absolute));
    
    httpWebRequest.BeginGetResponse(result =>
    {
        // Handle response
    }, null);
    
    var info = WebRequestExtensions.GetCurrentNetworkInterface(httpWebRequest);
    

    I had a similar problem recently and found you can’t call GetCurrentNetworkInterface before BeginGetResponse (because the connection hasn’t been made) but if you call it within the BeginGetResponse callback the request has already completed and you get the “Web request is already finished” error.

    ADDED by question-starter:

    Fully-worker code which allows to get NetworkInterfaceInfo of HttpWebRequest from background thread (used BackgroundWorker in this example to simulate this):

    BackgroundWorker backgroundWorker = new BackgroundWorker();
    backgroundWorker.DoWork += (s, 4) =>
    {
        HttpWebRequest httpWebRequest = HttpWebRequest.CreateHttp(new Uri("http://stackoverflow.com", UriKind.Absolute));
    
        EventWaitHandle Wait = new AutoResetEvent(false);
    
        httpWebRequest.BeginGetResponse(result =>
        {
            Wait.Set();
        }, null);
    
        Wait.WaitOne();
        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {                        
            var info = WebRequestExtensions.GetCurrentNetworkInterface(httpWebRequest);
            MessageBox.Show(info.InterfaceType.ToString());
        });
    };
    backgroundWorker.RunWorkerAsync();
    

    ADDED AFTER FULL-DAY DEBUGGING:
    I can’t make it work 100% time, especially when loaded page is small. In this situation “request is finished” appears all the time. But with large loaded page it works even without EventWaitHandle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get list which computers are online or offline on local network
I want to get the MAC address for my network interface on Linux. I
I want to get list of Domino Servers on the network, and accordingly login
Goal: To develop a web based NMS interface which displays a network topology (e.g.,
I have this document where i want to get to the value in x_server_response/retrieve_resources_by_category_response/source_full_info/record/
I want to get packages from a network using TCP/IP as a client. With
I want get the time used for a case so I can create an
I want get all of the Geom objects that are related to a certain
I want to get started doing some game development using Microsoft's XNA. Part of
I want to get the MD5 Hash of a string value in SQL Server

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.