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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:30:58+00:00 2026-05-11T10:30:58+00:00

I’ve got a problem here. I’ve got an ASP.net website hosting a silverlight 2

  • 0

I’ve got a problem here.

I’ve got an ASP.net website hosting a silverlight 2 application. I’d like the site to communicate to and fro from the silverlight app, and I’m doing this via http requests. Incidentally, if anyone knows a better way, please do tell me.

My server’s got the following http listener set up. I copied this from a tutorial site somewhere, since it’s mainly experimentation at the moment :

      HttpListener listener = new HttpListener (  );       listener.Prefixes.Add('http://localhost:4531/MyApp/');         listener.Start(  );                                                 // Wait for a client request:       HttpListenerContext context = listener.GetContext(  );        // Respond to the request:       string msg = 'You asked for: ' + context.Request.RawUrl;       context.Response.ContentLength64 = Encoding.UTF8.GetByteCount (msg);       context.Response.StatusCode = (int) HttpStatusCode.OK;        using (Stream s = context.Response.OutputStream)       using (StreamWriter writer = new StreamWriter (s))         writer.Write (msg);        listener.Stop(  ); 

I’m using the following code to send a request :

 private void MyButton_Click(object sender, RoutedEventArgs e)         {             Button b = sender as Button;             b.Content = 'Hello World';              Uri serviceUri = new Uri('http://localhost:4531/MyApp/');             WebClient downloader = new WebClient();             downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(TestDownloadStoriesCompleted);             downloader.DownloadStringAsync(serviceUri);          }         void TestDownloadStoriesCompleted(object sender, DownloadStringCompletedEventArgs e)         {             if (e.Error == null)             {                 TextBox1.Text = e.Result;             }         } 

My problem is that I can connect to the webserver from a console application using pretty much the same code (I tested it by setting a breakpoint in the code), however nothing happens when I click the button in silverlight. (I’ve added the ‘Hello World’ to test that I am indeed connecting the delegate to the button.)

I’ve read that silverlight needs policies to connect via webclient, but it shouldn’t be the case if I’m using the same server and the same domain for both the server and the silverlight application!

Thanks for all your replies!

EDIT : I am recieving this exception :

System.Security.SecurityException —> System.Security.SecurityException: Security error.

Also, based on what I’m reading apparently to be site-of-origin, the deployment URI of the xap and the request URI must also be of the same port.

However, when I set the properties for the server to be hosted on a specific port, and I set the listener to listen to that same port, it fails with the message that The process cannot access the file because it is being used by another process. I assume it is because the http listener can’t listen to the same port being used to host it 😐 But then how can I make Silverlight perform host of origin webclient requests?

  • 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. 2026-05-11T10:30:59+00:00Added an answer on May 11, 2026 at 10:30 am

    Since this is only a test add an ‘else TextBox1.Text=e.Error.ToString();’ in your TestDownloadStoriesCompleted handler to see what error you get.

    EDIT:

    You can’t host both the asp.net app and your listener on the same port – you could fix this by using a different port and serving a clientaccesspolicy.xml from your httplistener.

    However I think it would make more sense for you to take a look at WCF web services (you add the svc to your asp.net app). Here’s a sample.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Welcome to the IE box model bug May 11, 2026 at 7:39 pm
  • Editorial Team
    Editorial Team added an answer Lack of portability - they are mainly a Unix thing.… May 11, 2026 at 7:39 pm
  • Editorial Team
    Editorial Team added an answer You probably need to do a direct GRANT of DBA_JOBS_RUNNING… May 11, 2026 at 7:39 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

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.