|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I have created a Mobile Application in C# .net.
I am sending a WAPPush SMS for users who may request Mobile Services such as (Ringtones, Pictures). I have a problem in downloading ringtone(True Tone of file extension AMR) on WAP Browser, the ringtone name is not saved. After downloading the Ringtone file takes the link file name "userlink" which appears in url(ex, url: http://IP/webapplication?userlink.aspx?pwd=887768).The file name (amr) is not known on WAP Browser, so I am sending the link to users to download it .The idea is I can download file type AMR (or in MP3...) from my Web Browser but it is not saved on mobile handset in its real name just it can be heard. Also I am giving the file name through this syntax: Response.AppendHeader("Content-Disposition", "attachment;filename="+ szFileName.Trim()); The code is Below: Please help to fix my problem as soon as possible ...........//********************************************* private void Download(int szID) { string szContent=""; string szType=""; string szFileName=""; SqlConnection Conn = new SqlConnection(objGeneral.GetConnect()); string sqlselect="SELECT ContentUrl,Type,ContentName FROM ContentType where ID='"+szID+"' "; Conn.Open(); SqlCommand CmdObj = new SqlCommand(sqlselect, Conn); SqlDataReader ReaderObj = CmdObj.ExecuteReader(); if(ReaderObj.Read()) { Response.Clear(); szContent=ReaderObj.GetString(0); szType=ReaderObj.GetString(1); szFileName=ReaderObj.GetString(2); FileInfo f = new FileInfo("C:\\Inetpub\\wwwroot\\MobileServices\\"+szContent); Response.Clear(); Response.AppendHeader("Content-Disposition:inline", "attachment;filename="+ f.Name); Response.AddHeader("Content-Length", f.Length.ToString()); //Response.ContentType=szType ; Response.ContentType="text/vnd.wap.wml"; Response.AddHeader("pragma","no-cache"); if(!ReaderObj.IsDBNull(2)) { Response.WriteFile(f.FullName); Response.End(); } else { Response.Write("no image exists!!"); } ReaderObj.Close(); } } Regards, Ranine |
|
#2
|
||||
|
||||
|
Hi Ranine,
Welcome to Dev Shed. I don't really know c# at all, but shouldn't the content type be set to match the type of the file you are trying to download. (eg: audio/mpeg for mp3) You have it as Good list here if you are needing more info on mime types ....
__________________
Cheers, Jamie # mdb4u | The mobile movie database | Please help to test and promote # skiFFie | Home of the 'accessibility module' for Drupal # Jamie Burns [me] Accessibility Module [drupal] # guidelines | search | wap resources | not getting help | fold to cure __________________ Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. ![]() __________________ |
|
#3
|
|||
|
|||
|
Quote:
hi Jabba: Yes that's right the content type should match the file type which is retrieved from Database. But as I told you the Ringtone file wasn't saved on my mobile after downloading. Here in the code above I was trying to change the Response.ContentType="text/vnd.wap.wml"; it has given me this error: //************************* HTTP Error : 400 (Bad Request) <html><body>Bad Request</body></html> //********************************* I think that maybe the main reason for such error as the source code userlinks.aspx. Please Jabba in your opinion do I have to change the C# code into WML? if So can you help me.... Regards, Ranine |
|
#4
|
||||
|
||||
|
Is userlink.aspx the page that the snippet of code is taken from?
The file is actually in a database - is it stored in the correct format there? Have you tried the same code but made it available to a web browser so that you can test that it works and that the format is correct? Your uri has "?pwd=887768" where presumably pwd relates to ID='"+szID+"' in your query - is your query successful - you don't seem to show any error trapping *. * That may just be my lack of knowledge in c# though ![]() |
|
#5
|
|||
|
|||
|
Quote:
Hi Jabba, Thanks on your reply. The userlink.aspx is the snippet of Code which is taken from. I have traced my code more than 100 times , and all what are retrieved from Database are correct like :Content name, Content length (appending the specific headers) , the correct file path..... I am in need for help !The ringtone is saved as userlink.mp3 so it takes the file extension and it is heard properly but what about the file real name???? I can accept converting my code into WML wireless markup language maybe it will work ! Regards, Ranine |
|
#6
|
|||
|
|||
|
Hello Jabba:
I have done the conversion from C# into Asp code in the wml page. Maybe through way I can solve the problem. Please can you check this code and tell me if I have to do any changes. Code: <?xml version="1.0"> <!DOCTYPE wml PUBLIC="-//WAPFORUM//DTD WML 1.1//EN" http://www.wapforum.org/STS/wml_1.1.xml> <wml> <% szpwd=request("pwd"); SubmitUserLink(); private void SubmitUserLink() { int szID=0; string szFilename=""; '***************************************************************************// '********************Submit Service******************************************// 'to download any mobile service, active should be 0 dim Con set Con = server.CreateObject("ADODB.Connection") Con.open "DSN=MobileService;uid=sa;pwd=Mediatech1" 'Create a recordset set myRecordSet = server.createObject("ADODB.Recordset") dim sql="Select ContentURL,Active,ContentID from WebLog where password='"+szpwd+"'and Active<='1'" myRecordSet.Open sql,Con,adOpenStatic 'Read records if myRecordSet.EOF !=null then szContent=myRecordSet.GetString(0) szActive=myRecordSet.GetString(1) szID=myRecordSet.GetString(2) UpdateWebLog() DownloadContent(szID) 'Response.Redirect(szContent,true) 'Close connections myRecordSet.Close Con.Close set myRecordSet=Nothing else Response.Write("Sorry you can't access this link because you've downloaded its content previously!") } public string UpdateWebLog() { '*****************Update WebLog********************************************// szActive+=1; dim Con set Con = server.CreateObject("ADODB.Connection") Con.close Con.open "DSN=MobileService;uid=sa;pwd=Mediatech1" set myRecordSet = server.createObject("ADODB.Recordset") rs.Open "Exec UpdateWebLog " & szpwd & szActive ,Con 'Close connections myRecordSet.Close Con.Close set myRecordSet=Nothing return "update" } private void DownloadContent(int szID) { byte[] byteArray=null; string szContent=""; int fileSize=0; string szType=""; dim Con set Con = server.CreateObject("ADODB.Connection") Con.open "DSN=MobileService;uid=sa;pwd=Mediatech1" set myRecordSet = server.createObject("ADODB.Recordset") string sqlselect="SELECT * FROM ContentType where ID='"+szID+"' "; myRecordSet.Open sqlselect,Con,adOpenStatic 'Read records if myRecordSet.EOF !=null then Response.Expires = 0; Response.Buffer=true; Response.Clear(); byteArray=(byte[]) myRecordSet["ContentBinary"]; szContent=myRecordSet.GetString(6); szType=myRecordSet.GetString(7); fileSize=byteArray.Length ; Response.AddHeader("Content-Length", szContent.Length.ToString()); Response.ContentType=szType ; Response.AppendHeader("Content-Disposition", "attachment;filename="+ szContent); Response.AddHeader("pragma","no-cache"); if(!myRecordSet.IsDBNull(2)) { BinaryReader bReader=new BinaryReader(new MemoryStream(byteArray)); Response.BinaryWrite(bReader.ReadBytes((int) bReader.BaseStream.Length)); Response.Flush(); Response.End(); bReader.Close(); } else { Response.Write("no image exists!!"); } } } %> </wml> ****************************************** Thanks Ranine |
|
#7
|
|||
|
|||
|
mp3 file download as .aspx file and not open on phone player
I have the same problem , i also create a mobile application ain asp.net to download mp3 file on cell phone.
But i find that when i access the page from cell phone , file save and displayed as wapauthenticate.aspx not as <filename>.mp3, opened by the media player after downloading? For more reference i add my download code string Name = dsDownload.Tables[0].Rows[0]["RingtoneFileName"].ToString(); string Format = dsDownload.Tables[0].Rows[0]["RingtoneFileFormat"].ToString(); string strFileName = Name + "." + Format; //THIS CODE IS WRITTEN TO INCREMENT THE NO OF COUNT IN THE DATABASE //IncrementFileDownloadCount(RingtoneID); //CODE END 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.Clear(); response.ClearContent(); response.ClearHeaders(); response.Buffer = true; response.AddHeader("Content-Disposition", "attachment;filename=\"" + originalFilename + "\""); Response.AddHeader("Content-Type", "audio/mpeg"); byte[] data = req.DownloadData(localfilename); response.BinaryWrite(data); response.End(); return; Please help me out from this problem |
|
#8
|
||||
|
||||
|
Welcome yoge.
This thread is over a year old, and am sure the OP has long gone. Please do not cross post. You have already started another thread, leave this one be ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Mobile Programming > Ringtone file name is not saved on my mobile handset |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|