Hi,
I've done an application that has a radUpload control. If I try the control in my local machine I'm able to upload, save and open the files. But when I publish the application I try to upload a file and I get the 0% uploading state and the file never gets uploaded.
Unhandled Error in Silverlight Application The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Telerik.Windows.Controls.FileUploader.OnResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
I try to upload allready exists file i give an error message that access denied.
.xaml file:
| <telerikInput:RadUpload |
| x:Name="RadUploadLogo" |
| Margin="0,173,8,0" |
| HorizontalAlignment="Right" |
| Width="310" |
| Filter="Resim Dosyaları (*.jpg;*.jpeg;*.png)|*.jpg;*.jpeg;*.png|Tüm Dosyalar (*.*)|*.*;" |
| IsMultiselect="False" |
| FilterIndex="0" |
| OverwriteExistingFiles="True" |
| UploadServiceUrl="~/MyUploadHandler.ashx" |
| TargetFolder="Images/MusteriLogolari" |
| VerticalAlignment="Top" Height="170" Background="#35000000" BorderBrush="White"/> |
c# code :
| void RadUploadLogo_FileUploadStarting(object sender, FileUploadStartingEventArgs e) |
| { |
| //e.FileParameters.Add("Authorized", "True"); |
| string fileName = App.appKullaniciTanimi.cKodHesap; |
| int i = e.UploadData.FileName.LastIndexOf('.'); |
| if (i >= 0 && i < e.UploadData.FileName.Length) |
| { |
| fileName += e.UploadData.FileName.Substring(i); |
| } |
| GonderilenDosya = fileName; |
| e.UploadData.FileName = fileName; |
| } |
MyUploadHandler.ashx :
| using System; |
| using System.Web; |
| using Telerik.Windows.Controls; |
| namespace QuipusBilisimB2B.Web |
| { |
| public class MyUploadHandler : Telerik.Windows.RadUploadHandler |
| { |
| public override void ProcessStream() |
| { |
| string authorized = this.Request.Form["Authorized"]; |
| bool isOK = !string.IsNullOrEmpty(authorized) && authorized.ToLower() == "true"; |
| //if (!isOK) |
| //{ |
| // ////this.CancelRequest(); |
| // ////this.Result.Add("Error", "Security token is required. Please login."); |
| // ////this.AddReturnParam("Error", "Security token is required. Please login."); |
| // this.AddReturnParam(RadUploadConstants.ParamNameMessage, "Security token is required. Please login."); |
| // string fileName = this.Request.Form[RadUploadConstants.ParamNameFileName]; |
| // string filePath = this.GetFilePath(fileName); |
| // this.AddReturnParam(RadUploadConstants.ParamNameSuccess, false); |
| // this.AddReturnParam(RadUploadConstants.ParamNameFileIdent, filePath); |
| // this.AddReturnParam(RadUploadConstants.ParamNameFileName, fileName); |
| // this.AddReturnParam(RadUploadConstants.ParamNameFilePath, filePath); |
| // this.AddReturnParam(RadUploadConstants.ParamNameFinalFileRequest, true); |
| // return; |
| //} |
| base.ProcessStream(); |
| } |
| } |
| } |