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

  • Home
  • SEARCH
  • 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 800649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:19:19+00:00 2026-05-14T23:19:19+00:00

Problem: (Solution at the end) I got a Silverlight App with-in a Web Project

  • 0

Problem:
(Solution at the end)
I got a Silverlight App with-in a Web Project

Web

Silverlight

The web contains a service:

[WebService(Namespace = "svChat")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
//[System.Web.Script.Services.ScriptService]
public class GetIPService : System.Web.Services.WebService 
{

    public GetIPService () 
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string GetIp() 
    {
        return HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        
    }
  }

And I got a class in my Silverlight App using the Service:

public class Client
{
    private string ip;
    private string created;

    #region Properties
    public string Ip
    {
        get { return ip; }
        set { ip = value; }
    }

    public string Created
    {
        get { return created; }
        set { created = value; }
    }
    #endregion

    public Client()
    {
    }

    public void SetIp()
    {
        ServiceReference1.GetIPServiceSoapClient scIpClient = new svChat.ServiceReference1.GetIPServiceSoapClient();
        scIpClient.GetIpCompleted += new EventHandler<svChat.ServiceReference1.GetIpCompletedEventArgs>(IpService_Completed);
        scIpClient.GetIpAsync();
    }

    private void IpService_Completed(object sender, ServiceReference1.GetIpCompletedEventArgs e)
    {
        this.ip = e.Result;
    }

}

After Client is created, SetIp() is called, and Client.Ip is added to a text box.
Nothing happens.
Ip = null.

Service itselfs works, tested it.
Getting Ip by the above code works.

Gettings Ip via service through Silverlight App does not work.

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="GetIPServiceSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:2090/svChat.Web/GetIPService.asmx"
                binding="basicHttpBinding" bindingConfiguration="GetIPServiceSoap"
                contract="ServiceReference1.GetIPServiceSoap" name="GetIPServiceSoap" />
        </client>
    </system.serviceModel>
</configuration>

Any ideas?

regards,

Solution:
Creating a Silverlight Application within VS 2010 (Ultimate) causes VS to use the same test-server for the silverlight application and the website.
This is no problem until VS uses the Silverlight configuration to set up the test server.
The silverlight client will now not be able to correctly access the webservers webservice.
The exact reason is not known, but I think it’s caused by the above described situation.
So start debug, and wait until website is loading and "Exception" pops up, then "Stop" debugging, and continue testing the website withouth worrying about exceptions.
Disadvantage: No debugging.

  • 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-14T23:19:19+00:00Added an answer on May 14, 2026 at 11:19 pm

    I guess the key thing is to confirm that the request to the Web Service does include the Http header HTTP_X_FORWARDED_FOR which is normally added by a proxy server or load balancer.

    If this header does not exist then the result of the call to

    HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; 
    

    is null, which is what you are seeing. Since the end point you are showing in the configuration points to localhost, you are definately not going through a proxy or a load balancer so there would not be a HTTP_X_FORWARDED_FOR header added.

    http://localhost:2090/svChat.Web/GetIPService.asmx

    If you are not going through a proxy or load balancer you can look use REMOTE_ADDR (with varying degree of success)

    HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]
    

    Regardless, you should probably write your code to handle the fact that neither of these might actually have anything set. You cannot assume every proxy or lad balancer will add the HTTP_X_FORWARDED_FOR header, unless you controll all infrastrucutre components between the client and the server.

    Update: Based on the code you provided, here are the changes I made.

        public MainPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Page_Loaded);
            this.MainClient = new Client();
            ClientList.Clients.Add(this.MainClient);
    
            // Removed LoadXMLFile call here, constructor runs before Loaded event.
            //LoadXMLFile();
        }
    
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            svChat.ServiceReference1.GetIPServiceSoapClient scIpClient = new svChat.ServiceReference1.GetIPServiceSoapClient();
            scIpClient.GetIpCompleted += new EventHandler<svChat.ServiceReference1.GetIpCompletedEventArgs>(IpService_Completed);
    
            scIpClient.GetIpAsync();
        }
    
        public void IpService_Completed(object sender, svChat.ServiceReference1.GetIpCompletedEventArgs e)
        {
            this.MainClient.Ip = e.Result;
            // Probably where you should call LoadXMLFile
            // at this point the async call has returned and 
            // the ip is intitialized.
            LoadXMLFile();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 405k
  • Answers 405k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The T-Log will only have portions of it marked inactive,… May 15, 2026 at 5:44 am
  • Editorial Team
    Editorial Team added an answer You rarely have to create objects for the basic data… May 15, 2026 at 5:44 am
  • Editorial Team
    Editorial Team added an answer If you have negative lookaheads you can use that: /warnings?(?!\.gif)/… May 15, 2026 at 5:44 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.