This is a migrated thread and some comments may be shown as answers.

can't read querystring value in SaveChunkData method

1 Answer 51 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 25 Apr 2011, 06:05 PM
I rearrange my code to make it work with the SaveChunkData method. Unfortunately I can't read the querystring value in the SaveChunkData method. I have tried the following, the threadID is always null even tough I see a value in the querystring:

//http://localhost/myapp/User/MultiPhotoUpload.aspx?threadID=20&threadTypeID=3
                //HttpContext.Current.Handler.ProcessRequest(HttpContext.Current);
                HttpContext.Current.CurrentHandler.ProcessRequest(HttpContext.Current);

                HttpRequest request = Context.Request;

                string testRequest = request.QueryString["threadID"];

                string thisFormThreadID = this.Request.Form["threadID"];

                string thisThreadID = this.Request.QueryString["threadID"];

              //HttpContext context = new base.Request.QueryString["threadID"];

                string testThreadID = HttpContext.Current.Request.QueryString["threadID"];

                string formThreadID = HttpContext.Current.Request.Form["threadID"];

                //HttpContext.Current.Handler.ProcessRequest(HttpContext.Current);

                string baseThreadID = base.Request.QueryString["threadID"];

                string contextThreadID = base.Context.Request.QueryString["threadID"];

                string threadID = Context.Request.QueryString["threadID"];

Here is my SaveChunkData method, why is my threadID value always null. I must not understand something, please enlighten me, thanks.

 

 

public

 

 

override bool SaveChunkData(string filePath, long position, byte[] buffer, int contentLength, out int savedBytes)

 

 

{

 

 

 

bool result = base.SaveChunkData(filePath, position, buffer, contentLength, out savedBytes);

 

 

 

 

try

 

 

 

 

 

 

 

{

 

 

 

if (this.IsFinalFileRequest())

 

 

{

 

 

 

//If the file is successfully uploaded.

 

 

 

 

 

 

 

 

 

if (result)

 

 

{

 

 

 

string threadID = this.Request.Form["threadID"];

 

 

 

 

if (!String.IsNullOrEmpty(this.Request.Form["threadID"]))

 

 

{

 

 

 

if (!SYLWebUtility.ImageHelper.VerifyDirectoryExistsForNewFile(this.GetFilePath()))

 

 

{

 

 

 

this.AddReturnParam(RadUploadConstants.ParamNameMessage, UserInterfaceMessages.UserInterfaceMessage.ErrorMessage(UserInterfaceMessages.Enumerations.UIErrorMessage.ProblemsAddingData, SYLWebUtility.LanguageHelper.GetLanguageIDByTwoLetterISOLanguageName()));

 

 

 

 

this.ReturnMandatoryParameters(result, this.IsFinalFileRequest());

 

 

 

 

return result;

 

 

}

 

 

 

this.SaveFiles();

 

 

}

 

 

 

else

 

 

 

 

 

 

 

{

 

 

 

if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))

 

 

{

 

 

 

//Deletes the specified file. An exception is not thrown if the specified file does not exist.

 

 

 

 

 

 

 

System.IO.

 

File.Delete(this.GetFilePath());

 

 

}

 

}

 

}

 

}

 

ReturnMandatoryParameters(result,

 

this.IsFinalFileRequest());

 

 

 

 

return result;

 

 

}

 

 

 

catch (Exception)

 

 

{

 

 

 

if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))

 

 

{

 

 

 

//Deletes the specified file. An exception is not thrown if the specified file does not exist.

 

 

 

 

 

 

 

System.IO.

 

File.Delete(this.GetFilePath());

 

 

}

 

ReturnMandatoryParameters(result,

 

this.IsFinalFileRequest());

 

 

 

 

return result;

 

 

}

 

 

 

}

 

 

 

 

 

public

 

 

override bool SaveChunkData(string filePath, long position, byte[] buffer, int contentLength, out int savedBytes)

 

 

{

 

 

 

 

bool result = base.SaveChunkData(filePath, position, buffer, contentLength, out savedBytes);

 

 

 

 

 

try

 

 

 

 

 

 

 

 

 

{

 

 

 

 

if (this.IsFinalFileRequest())

 

 

{

 

 

 

 

//If the file is successfully uploaded.

 

 

 

 

 

 

 

 

 

 

 

 

if (result)

 

 

{

 

 

 

 

string threadID = this.Request.Form["threadID"];

 

 

 

 

 

if (!String.IsNullOrEmpty(this.Request.Form["threadID"]))

 

 

{

 

 

 

 

if (!SYLWebUtility.ImageHelper.VerifyDirectoryExistsForNewFile(this.GetFilePath()))

 

 

{

 

 

 

 

this.AddReturnParam(RadUploadConstants.ParamNameMessage, UserInterfaceMessages.UserInterfaceMessage.ErrorMessage(UserInterfaceMessages.Enumerations.UIErrorMessage.ProblemsAddingData, SYLWebUtility.LanguageHelper.GetLanguageIDByTwoLetterISOLanguageName()));

 

 

 

 

 

this.ReturnMandatoryParameters(result, this.IsFinalFileRequest());

 

 

 

 

 

return result;

 

 

}

 

 

 

 

this.SaveFiles();

 

 

}

 

 

 

 

else

 

 

 

 

 

 

 

 

 

{

 

 

 

 

if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))

 

 

{

 

 

 

 

//Deletes the specified file. An exception is not thrown if the specified file does not exist.

 

 

 

 

 

 

 

 

 

System.IO.

 

 

File.Delete(this.GetFilePath());

 

 

}

 

}

 

}

 

}

 

ReturnMandatoryParameters(result,

 

 

this.IsFinalFileRequest());

 

 

 

 

 

return result;

 

 

}

 

 

 

 

catch (Exception)

 

 

{

 

 

 

 

if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))

 

 

{

 

 

 

 

//Deletes the specified file. An exception is not thrown if the specified file does not exist.

 

 

 

 

 

 

 

 

 

System.IO.

 

 

File.Delete(this.GetFilePath());

 

 

}

 

ReturnMandatoryParameters(result,

 

 

this.IsFinalFileRequest());

 

 

 

 

 

return result;

 

 

}

 

 

 

}

 

public

 

 

override bool SaveChunkData(string filePath, long position, byte[] buffer, int contentLength, out int savedBytes)

 

 

{

 

 

 

bool result = base.SaveChunkData(filePath, position, buffer, contentLength, out savedBytes);

 

 

 

 

try

 

 

 

 

 

 

 

{

 

 

 

if (this.IsFinalFileRequest())

 

 

{

 

 

 

//If the file is successfully uploaded.

 

 

 

 

 

 

 

 

 

if (result)

 

 

{

 

 

 

string threadID = this.Request.Form["threadID"];

 

 

 

 

if (!String.IsNullOrEmpty(this.Request.Form["threadID"]))

 

 

{

 

 

 

if (!SYLWebUtility.ImageHelper.VerifyDirectoryExistsForNewFile(this.GetFilePath()))

 

 

{

 

 

 

this.AddReturnParam(RadUploadConstants.ParamNameMessage, UserInterfaceMessages.UserInterfaceMessage.ErrorMessage(UserInterfaceMessages.Enumerations.UIErrorMessage.ProblemsAddingData, SYLWebUtility.LanguageHelper.GetLanguageIDByTwoLetterISOLanguageName()));

 

 

 

 

this.ReturnMandatoryParameters(result, this.IsFinalFileRequest());

 

 

 

 

return result;

 

 

}

 

 

 

this.SaveFiles();

 

 

}

 

 

 

else

 

 

 

 

 

 

 

{

 

 

 

if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))

 

 

{

 

 

 

//Deletes the specified file. An exception is not thrown if the specified file does not exist.

 

 

 

 

 

 

 

System.IO.

 

File.Delete(this.GetFilePath());

 

 

}

 

}

 

}

 

}

 

ReturnMandatoryParameters(result,

 

this.IsFinalFileRequest());

 

 

 

 

return result;

 

 

}

 

 

 

catch (Exception)

 

 

{

 

 

 

if (SYLWebUtility.ImageHelper.VerifyFileExists(this.GetFilePath()))

 

 

{

 

 

 

//Deletes the specified file. An exception is not thrown if the specified file does not exist.

 

 

 

 

 

 

 

System.IO.

 

File.Delete(this.GetFilePath());

 

 

}

 

ReturnMandatoryParameters(result,

 

this.IsFinalFileRequest());

 

 

 

 

return result;

 

 

}

 

 

 

}

 

 

 

                //string threadID = HttpContext.Current.Request.QueryString["threadID"];

                //string tID = this.Request.Form["threadID"];

                //string thID = this.Request.QueryString["threadID"];

                //string threadID = Request.QueryString["threadTypeID"];



1 Answer, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 28 Apr 2011, 12:13 PM
Hi Patrick,

The RadUpload will send requests to the RadUploadHandler's url and it is not the same request as the one of the page. If you want to pass query string parameters to the RadUploadHandler, I would recommend passing them as upload handler service parameters from the silverlight control

Kind regards,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Upload
Asked by
Patrick
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Share this question
or