How To Get Silverlight To Play A .WMA File on IIS 6 When The .WMA Extn. Is Mapped To Asp.Net
I seem to have hit a bit of a wall on this one - although everything works fine on XP Pro IIS5.1, on IIS 6 I have tried everything over the last few days to get silverlight to simply play a .wma file when the .wma file extension is mapped to .Net in IIS (via Home Directory > confi开发者_JS百科guration, map the extension to c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll. ) - without success !! The file plays ok so long as the .wma file-type isn't mapped to .net, but as soon as it is, I keep getting a generic "System.Exception - 3137" error message - which I believe is a file not found/file inaccessible message.
The .wma file that won't play is not compiled as a resource into the silverlight .xap - I am attempting to access it with it just being a normal part of the folder/file structure on the server. I have tried many different combinations of path, but presumably the path is correct as the file plays ok when the .wma extension isn't mapped to .net. The code within the SL app setting the source is : mediaPlayer.Source = new Uri("http://www.thedomainname.org.uk/radio/featuredartistsplaylists/poprock.wma", UriKind.Absolute); - although I have also tried relative paths from the .xap file (with and without a leading '/'), the absolute path using the ip address rather than the domain name (which gave a network error) and relative file system path in back\slash format (which gave a network error). - for authentication, anonymous access is enabled on IIS for windows user account IUSR_HOST-7418 and as well as not setting the mode in web.config at all I have tried setting it to mode="none" and mode="windows"
My web-hosting set-up is a VPS running Windows Server 2003 Standard. I don't really know what I am doing, but I have tried the following to no effect :
- In the IIS configuration mapping dialogue, trying with the 'verify that file exists' checkbox checked and unchecked
- adding a <httpHandlers> entry for .wma in the <system.web> tag of web.config as follows :
<path "*.wma" verb="*" type="System.Web.UI.PageHandlerFactory" validate="false" />
(and tried it with validate="true")
- running the request with and without a global.asax and with a code-free Application_BeginRequest event - in case my code in global.asax was blocking access to the .wma
- granted Read & Execute rights on the folder containing the .wma to both the Internet Guest Account(HOST-7418\IUSR_HOST-7418) and Users(HOST-7418/Users) Account.
At this point, beyond suspecting that it is some sort of file/folder access issue rather than a path issue, I am pretty much out of ideas - not least because I encountered an identical problem on a Windows Server 2008 (IIS 7) VPS set-up - with .wma files again only playing when not mapped to .net (using compiled handlers/modules), otherwise refusing to play due to "System.Exception : 2210 AG_E_INVALID_ARGUMENT" error code.
Any help would be very much appreciated.
Couple things - first off, WMA shouldn't need to be mapped to the .NET handler. It's just a static file being served off a web server, so don't worry about any of the handler or web.config stuff. A plain vanilla IIS web site should do you just fine.
First, test your server configuration.
If your file is at http://www.mywebserver.com/SampleFile.wma
, open up Windows Media Player, go to File > Open URL, and put that full URL in and make sure it plays. If it doesn't, Silverlight isn't going to work.
Once that's working, the Silverlight MediaElement can use 2 methods of Windows Media streaming - Progressive Download or Streaming. Progressive Download is your current scenario, streaming requires Windows Media Services and can be done over the RTSP protocol (MMS) or HTTP.
To help with your testing and for comparison, I've put a sample WMA out for you to test with using these 3 scenarios:
Progressive Download (plain ol' web server): http://static.x9tech.com/StackOverflow/WithoutASoundSample.wma
Streaming (WMS over MMS): mms://xstream5.x9tech.com/Static/StackOverflow/WithoutASoundSample.wma
Streaming (WMS over HTTP): http://xstream5.x9tech.com/Static/StackOverflow/WithoutASoundSample.wma
精彩评论