Old 1st September 2003, 01:08   #1
Junior Member
Join Date: Sep 2003
Posts: 1
Send a message via AIM to j3507
problem when accessing xml stats with asp.net .aspx

i can access the xml stats in internet explorer using the following link..
but when i try to access it through asp.net i get an error:
The remote server returned an error: (404) Not Found

and in the shoutcast server log i get:
<08/31/03@18:53:25> [dest:] Invalid resource request(/admin.cgi?pass=password&mode=viewxml)

this seems to be the only problem, and it really sucks. i dont know where to go from this, just wondering if anyone else has encountered this problem..or if i should be asking for help elsewhere (i.e. an asp.net forum)
i've seen some php scripts around and casterclub.com has an asp implementation but i'd really like to get this to work in asp.net,
if anyone can help it would be greatly appreciated..
j3507 is offline   Reply With Quote
Old 1st September 2003, 01:13   #2
Senior Member
biscoradio's Avatar
Join Date: Jun 2002
Location: Chicago
Posts: 126
I have an asp script that works, and I also know a bit about .net and xml parsing, server config, and all that good stuff. If you want to send me the script, I'll take a look at it, can recompile it for my server and see if I can get it to work. email it to me at rob@biscoradio.com if you want.
biscoradio is offline   Reply With Quote
Old 11th July 2006, 03:22   #3
Junior Member
Join Date: Jul 2006
Location: Antofagasta, Chile
Posts: 3
Send a message via Yahoo to ahumeniy
I'm having the same issue with XML statistics. It gives me an "The server committed a protocol violation." error message.

I've tried editing the web.config file with the lines:

<httpWebRequest useUnsafeHeaderParsing="true"/>

but it now gives me an 404 error (!) wich -i guess- is the same that j3507 is getting.

When I tried opening the file in Visual Studio 2005 IDE it doesn't parse the XML correctly (it shows it as a single line of code). In other forums y read that the "The server committed a protocol violation." could be because a bad formatted XML file ¿?

However, if I download the file and then I make the program read de XML from hard disk it works fine, so I am looking for a way to automate the manual download of the file as an alternative, but it cannot be done with .NET built-in classes because it gives the same error.

Also, I made a console application -to be sure it isn't a token issue with the ASPNET account- and it gave me the same error.

Well, I hope that that issue will be investigated and -if necessary- a patch or new version released.
ahumeniy is offline   Reply With Quote
Old 11th July 2006, 07:10   #4
Winamp's Womble
bored_womble's Avatar
Join Date: May 2004
Location: Wimbledon Common
Posts: 1,100
the issue *sounds* like you are not setting the User-Agent correctly.

It needs to contain 'Mozilla' for the Shoutcast server to realise you are not a listening client and response correctly.

When sending a request the string is someting like

GET /admin.cgi&pass=<admin password>
User-Agent: Mozilla
Host: <a.b.c.d>

There can be extra stuff, but that is really all you need, and yes you can encode the password with base64 if you like.

Give it a whirl.


Without open minds the world will die. Open yours and correct the mistakes you are making right now.
bored_womble is offline   Reply With Quote
Old 11th July 2006, 15:10   #5
Junior Member
Join Date: Jul 2006
Location: Antofagasta, Chile
Posts: 3
Send a message via Yahoo to ahumeniy

Here is a small piece of code that generates a javascript that can be put in any webpage using the <javascript src=""/> statement. It only gives the songname currently playing, but it can be improved.

---begin code---
<%@ Page Language="C#" %>

<%@ Import Namespace="System.Xml" %>
XmlTextReader tr;
string SongTitle = "Not available"; //Message to show when there is no info.
string HDFile = "c:\\shoutcast.xml"; //Place where to download the XML from the server.
string RemoteFile = "http://localhost:8000/admin.cgi?pass=changeme&mode=viewxml&page=1"; //Addres from the XML files in the server. It can be in localhost
// Starting...
System.Net.WebClient wc = new System.Net.WebClient(); //We create a WebClient object to download the file.
if (System.IO.File.Exists(HDFile)) System.IO.File.Delete(HDFile); //We check if the file already exists in hard drive and delete it if necessary.
wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); //Here is the most important line to make this work.
wc.DownloadFile(RemoteFile, HDFile); // Getting XML from the ShoutCast server...
tr = new XmlTextReader(HDFile);
// Success! Retrieving the necessary information...
while (tr.Read())
if (tr.Name == "SONGTITLE")
// Gotcha!
SongTitle = tr.ReadString();
tr = null;
// Now Playing: '" + SongTitle + "'...
catch (Exception ex)
//Error detected, displaying error message. You can later make other way to handle an error.
SongTitle = "Error: " + ex.GetType().ToString() + ": " + ex.Message;
document.writeIn('<% Response.Write(SongTitle.Replace("\"", "\\\"")); %>');

---end of code---
ahumeniy is offline   Reply With Quote
Old 11th July 2006, 15:14   #6
Junior Member
Join Date: Jul 2006
Location: Antofagasta, Chile
Posts: 3
Send a message via Yahoo to ahumeniy
Well, MSDN says that the WebClient class does not give headers by default:

ahumeniy is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump