Skip to main content

Microsoft Silverlight

Answered Question Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?RSS Feed

(0)

barnabyjones
barnabyj...

Member

Member

10 points

7 Posts

Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?

I have a small custom project using silverlight that runs on a central server (192.168 address space) but needs to access locally hosted content. Setting the source of the mediaElement to http://localhost/file.wmv fails but setting it to http://127.0.0.1/file.wmv works. Can anyone tell me why this is?

 Thanks.
 

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?

I think localhost is resolved differently than 127.0.0.1...might not be going through the network stack by that name (this happens a lot in SQL Server addressing, it might be the same here).

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

barnabyjones
barnabyj...

Member

Member

10 points

7 Posts

Re: Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?

Thanks for the reply.

 I don't have any experience with SQL Server, but I don't think that is it: when I run the server locally on a machine, localhost works fine. When I move the server to a different machine on the same network, localhost doesn't work and I have to use 127.0.01 links. Could this be a byproduct of the silverlight plugin security model?

Thanks. 

Cass
Cass

Contributor

Contributor

3157 points

654 Posts

Re: Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?

why do you want to use the IP address or the localhost? Why don't you just use "appRoot"?

Psychlist1972
Psychlis...

Contributor

Contributor

6045 points

973 Posts

MicrosoftModerator

Re: Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?

When you try start->run->cmd and type "ping localhost" on that machine, do you get a response back? If not, then the lmhosts file in windows\drivers\etc (IIRC) may be missing the entry for localhost.

Pete

Silverlight.net Moderator
MVP: Silverlight, Silverlight Insider
Author: Silverlight in Action, 2nd Edition
POKE 53280,0 - My Blog

Opinions are my own. Oh, and I don't work for Microsoft.

barnabyjones
barnabyj...

Member

Member

10 points

7 Posts

Re: Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?

Thanks for replying.

The hosts file is set up correctly. What I need to know is why using localhost to specify media sources works when the base silverlight files are served off the local webserver but doesn't work when the base silverlight files are served off a remote server.

And to the other question, I cannot use approot because: I need to parse requests with a script to deliver the right files and the media sources will not be located in the approot anyway.

 Thanks
 

edmaia
edmaia

Member

Member

34 points

7 Posts

Answered Question

Re: Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?

This is due to the URL Access Policy enforced in Silverlight.  This is considered a cross-zone access, which is not allowed in Windows.

The full list of allowed accesses can be found at http://msdn2.microsoft.com/en-us/library/bb820909.aspx

Thanks,

Ed Maia
Silverlight Developer

barnabyjones
barnabyj...

Member

Member

10 points

7 Posts

Re: Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?

That is exactly what I needed to know. Thanks so much!

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities