Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Why does setting a media source to 127.0.0.1 work but setting it to localhost doesn't?
7 replies. Latest Post by barnabyjones on November 26, 2007.
(0)
barnabyj...
Member
10 points
7 Posts
11-21-2007 1:13 PM |
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
Star
8320 points
1,546 Posts
11-23-2007 7:06 PM |
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).
11-23-2007 7:29 PM |
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?
Cass
Contributor
3157 points
654 Posts
11-24-2007 6:42 PM |
why do you want to use the IP address or the localhost? Why don't you just use "appRoot"?
Psychlis...
6045 points
973 Posts
11-25-2007 9:02 PM |
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
11-26-2007 12:03 PM |
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
34 points
11-26-2007 1:17 PM |
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,
11-26-2007 1:26 PM |
That is exactly what I needed to know. Thanks so much!