I have developed one wap page using Microsoft Mobile control form in .net in c#.
On click of button, i need to download the mp3 file into cell phone. Its downloaded successfully to my cell phone. But open in the web page rather then in real player of my cell phone Nokia N 72. When I access the same page from Internet Browser like Mozilla, IE etc. then file save successfully and played in player.
For more Detail, i ma putting my code also.
protected void CmdDownload_Click(object sender, EventArgs e)
string originalFilename = strFileName;
string localfilename = Server.MapPath("~/RingtoneFiles") + "/" + strFileName;
WebClient req = new WebClient();
CredentialCache mycache = new CredentialCache();
mycache.Add(new Uri(localfilename), "Basic", new NetworkCredential("administrator", "admin$123"));
req.Credentials = mycache;
HttpResponse response = HttpContext.Current.Response;
response.Buffer = true;
response.AddHeader("Content-Disposition", "attachment;filename=\"" + originalFilename + "\"");
byte data = req.DownloadData(localfilename);
catch (Exception ex)
if (ex.Message == "The remote server returned an error: (404) Not Found.")
throw new Exception("File not found");
else if (ex.Message == "The remote server returned an error: (401) Unauthorized.")
throw new Exception("Unauthorized access");
Anyone can help me or can provide any sample code or link for solving my problem. I will be very greatfull to you.
PCs often recognise the downloaded file purely from the extension. If you want the mp3 file to be recognised by your phone on download then you need to serve it to the phone with the correct MIME type.
If there isn't a MIME type but you save the file and then open it on the phone it should work fine though.
Sorry, I answered your last post in a bit of a hurry, assuming I'd seen the same problem before.
It looks to me like you have some code which is supposed to run server side when you select a link and that code is being downloaded to the phone rather than the mp3 file, is that the case? Or is the mp3 file actually being downloaded but with the wrong name?
Definitely looks like a server side problem though.
thanks for response. what will happen with that case.
you are correct. on the click of button we are running server side code.
the result is following
1. file is downloaded to cell phone successfully.
2. its open in cell player like real player.
3. name of file display as <page name>.aspx not <file name>.mp3.
4. downloaded file is mp3 because we have tested this as follows
i. I connect my cell phone to pc via cable.
ii. I change the file extention .aspx-> .mp3.
iii. Now file start to play in pc and as well as in cell phone. And now its visible in cell phone also.
So it means that downloaded file is mp3 not an page. only its name become <page name>.aspx. So its not played by real player of cell phone initially.