Hi,
I read this article of few months ago: http://blogs.msdn.com/coding4fun/archive/2006/10/31/913360.aspx. I built my own site based on the code provided. Locally it worked perfect.
The problem is when I put it on my web server and try to access it from the web. There seems to be no playlist showing, where as when it ran locally I got loads of songs. It seems that the problem might be to do with the user. I did some crude experiments by putting some email code so I could see what was going on.
The first one is at page level:
The second one is in the database class provided by coding 4 fun:
When I ran it in visual studio I got a user and lots of songs in the playlist. Running it from IIS I got no user and no playlist.
I have read impersonation articles and tried adding the following to my web config:
After adding this the email logging still the user as blank.
Also read various articles such as: http://msdn2.microsoft.com/en-us/library/xh507fc5(VS.71).aspx. Up to now I stumped.
I wanted to add this to part of my site (with a login page to stop public access) so I could access all my music on my server at home from work.
Can anyone please help.
Dave.
I read this article of few months ago: http://blogs.msdn.com/coding4fun/archive/2006/10/31/913360.aspx. I built my own site based on the code provided. Locally it worked perfect.
The problem is when I put it on my web server and try to access it from the web. There seems to be no playlist showing, where as when it ran locally I got loads of songs. It seems that the problem might be to do with the user. I did some crude experiments by putting some email code so I could see what was going on.
The first one is at page level:
Visual Basic:
Protected Sub lgnAdmin_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles lgnAdmin.Authenticate
'Create an instance of the MailMessage class.
Dim objMM As New MailMessage()
'Set the properties.
objMM.To = "me@me.co.uk"
objMM.From = "me@me.co.uk"
objMM.BodyFormat = MailFormat.Html
objMM.Priority = MailPriority.High
'Set the subject.
objMM.Subject = "User/Password"
'Set the message.
objMM.Body = "Your user name is: " & User.Identity.Name
'Send the message, use the Send method of the SmtpMail class.
SmtpMail.Send(objMM)
If Me.lgnAdmin.UserName = System.Configuration.ConfigurationManager.AppSettings("UserName").ToString And Me.lgnAdmin.Password = System.Configuration.ConfigurationManager.AppSettings("Password").ToString Then
Response.Redirect("Admin.aspx")
Else
Me.lgnAdmin.InstructionText = "Sorry, your login details do not match!"
End If
The second one is in the database class provided by coding 4 fun:
Visual Basic:
Private Shared Sub Refresh()
Dim wmp As WindowsMediaPlayer = New WindowsMediaPlayer
Dim playlist As IWMPPlaylist = wmp.mediaCollection.getAll()
'Create an instance of the MailMessage class.
Dim objMM As New MailMessage()
'Set the properties.
objMM.To = "me@me.co.uk"
objMM.From = "me@me.co.uk"
objMM.BodyFormat = MailFormat.Html
objMM.Priority = MailPriority.High
'Set the subject.
objMM.Subject = "User/Password"
'Set the message.
objMM.Body = "Your user name is: " & My.User.Name & "<br/>Playlist count is: " & playlist.count.ToString
'Send the message, use the Send method of the SmtpMail class.
SmtpMail.Send(objMM)
Dim artistDictionary As Dictionary(Of String, Artist) = New Dictionary(Of String, Artist)
For i As Integer = 0 To playlist.count - 1
Dim media As IWMPMedia = playlist.Item(i)
Dim albumArtistName As String = media.getItemInfo("AlbumArtist")
Dim albumName As String = media.getItemInfo("Album")
Dim trackName As String = media.getItemInfo("Title")
Dim trackLocation As String = media.getItemInfo("SourceUrl")
Dim trackNumberString As String = media.getItemInfo("OriginalIndex")
Dim theArtist As Artist
Dim artistSortName As String = Artist.GetSortName(albumArtistName)
If Not artistDictionary.TryGetValue(artistSortName, theArtist) Then
theArtist = New Artist(albumArtistName)
artistDictionary.Add(artistSortName, theArtist)
End If
Dim theAlbum As AppCode.Album
If Not theArtist.Albums.TryGetValue(albumName, theAlbum) Then
theAlbum = New AppCode.Album(albumName, theArtist)
theArtist.Albums.Add(albumName, theAlbum)
End If
Dim theTrack As Track
If Not theAlbum.Tracks.TryGetValue(trackName, theTrack) Then
Dim trackNumber As Integer
If Integer.TryParse(trackNumberString, trackNumber) Then
theTrack = New Track(trackNumber, trackName, trackLocation)
Else
theTrack = New Track(trackName, trackLocation)
End If
theTrack.Album = theAlbum
theAlbum.Tracks.Add(trackName, theTrack)
End If
Next
ArtistList.AddRange(artistDictionary.Values)
ArtistList.Sort()
End Sub
When I ran it in visual studio I got a user and lots of songs in the playlist. Running it from IIS I got no user and no playlist.
I have read impersonation articles and tried adding the following to my web config:
Visual Basic:
<identity impersonate="true" userName="machine\me" password="pass"/>
Also read various articles such as: http://msdn2.microsoft.com/en-us/library/xh507fc5(VS.71).aspx. Up to now I stumped.
I wanted to add this to part of my site (with a login page to stop public access) so I could access all my music on my server at home from work.
Can anyone please help.
Dave.