I've implemented a custom handler, however, I get a null exception further down the stack which I can't step through. I'm wondering if I'm doing something wrong or if there is a bug in the handler. It seems to happen after the file upload is successful.
I get the following exception.
<!--
[NullReferenceException]: Object reference not set to an instance of an object.
at System.Web.Util.StringUtil.memcpyimpl(Byte* src, Byte* dest, Int32 len)
at System.Web.Util.StringUtil.UnsafeStringCopy(String src, Int32 srcIndex, Char[] dest, Int32 destIndex, Int32 len)
at System.Web.HttpWriter.Write(String s)
at Telerik.Web.UI.AsyncUpload.ResponseWriter.WriteToResponse(String response)
at Telerik.Web.UI.AsyncUploadHandler.ProcessUploadedFile()
at Telerik.Web.UI.AsyncUploadHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ScriptManager_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9cbdec3-c810-4e87-846c-fb25a7c08002%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2012.1.411.35%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3af1f77841-f126-4726-9fc2-0ee8be7d2341%3a16e4e7cd%3af7645509%3a24ee1bba%3af46195d3%3a2003d0b8%3a1e771326%3aaa288e2d%3aed16cbdc%3a874f8ea2%3ac172ae1e%3a19620875%3a9cdfc6e7%3ae330518b%3ac8618e41%3ae4f8f289%3a490a9d4e%3abd8f85e4%3a68f76a79%3a2a2fc429%3a7165f74%3ab7778d6c%3a52af31a4, line 13675 character 8
- I've set HttpHandlerUrl on RadAsynUpload to "~/EDocsAsyncUpload"
- I've added the handler in the .config: <add name="EDSExtendedRadAsyncUploader" verb="*" path="EDocsAsyncUpload" type="EDS.DNN.ExtendedAsyncUploadHandler.ExtendedAsyncUploadHandler, EDS.DNN.ExtendedAsyncUploadHandler"/>
- All permissions are set for the app pool user on the temp folder. I've allow all users access to the handler with this config: <location path="EDocsAsyncUpload"><system.web><authorization><allow users="*"/></authorization></system.web></location>
- Telerik.Web.UI version is 2012.1.411.35
- I'm using Windows 7. All browsers regardless of which plugin I use exhibit the same behaviour.
[Serializable]
public
class
ExtendedAsyncUploadResult : IAsyncUploadResult
{
public
string
TempFileName {
get
;
set
; }
public
bool
Valid {
get
;
set
; }
public
string
ValidationMessage {
get
;
set
; }
public
int
ContentLength {
get
;
set
; }
public
string
ContentType {
get
;
set
; }
public
string
FileName {
get
;
set
; }
public
int
Pages {
get
;
set
; }
public
ExtendedAsyncUploadResult()
{
this
.TempFileName =
string
.Empty;
this
.ValidationMessage =
string
.Empty;
this
.ContentType =
string
.Empty;
this
.FileName =
string
.Empty;
}
}
public
class
ExtendedAsyncUploadHandler : Telerik.Web.UI.AsyncUploadHandler
{
protected
override
IAsyncUploadResult Process(UploadedFile file, HttpContext context,
IAsyncUploadConfiguration configuration,
string
tempFileName)
{
IAsyncUploadResult result =
base
.Process(file, context, configuration, tempFileName);
ExtendedAsyncUploadResult extendedResult =
base
.CreateDefaultUploadResult<ExtendedAsyncUploadResult>(file);
extendedResult.TempFileName = tempFileName;
try
{
string
imagePath = Path.Combine(configuration.TempTargetFolder, tempFileName);
if
(File.Exists(imagePath))
{
ImagingService.ImagingServiceClient client
=
new
ImagingService.ImagingServiceClient(
"NetTcpBinding_IImagingService"
);
ImageServiceValidationResult validationResult = client.ValidateImage(
imagePath, Path.GetExtension(result.FileName));
extendedResult.Valid = validationResult.State
== ImageServiceValidationResult.ValidState.Valid;
extendedResult.ValidationMessage = validationResult.Errors.ToString();
extendedResult.Pages = validationResult.PageCount;
}
else
{
throw
new
Exception(
"File does not exist."
);
}
}
catch
(Exception ex)
{
extendedResult.ValidationMessage = ex.Message;
extendedResult.Valid =
false
;
}
return
extendedResult;
}
}
I get the following exception.
<!--
[NullReferenceException]: Object reference not set to an instance of an object.
at System.Web.Util.StringUtil.memcpyimpl(Byte* src, Byte* dest, Int32 len)
at System.Web.Util.StringUtil.UnsafeStringCopy(String src, Int32 srcIndex, Char[] dest, Int32 destIndex, Int32 len)
at System.Web.HttpWriter.Write(String s)
at Telerik.Web.UI.AsyncUpload.ResponseWriter.WriteToResponse(String response)
at Telerik.Web.UI.AsyncUploadHandler.ProcessUploadedFile()
at Telerik.Web.UI.AsyncUploadHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->
Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ScriptManager_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ac9cbdec3-c810-4e87-846c-fb25a7c08002%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2012.1.411.35%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3af1f77841-f126-4726-9fc2-0ee8be7d2341%3a16e4e7cd%3af7645509%3a24ee1bba%3af46195d3%3a2003d0b8%3a1e771326%3aaa288e2d%3aed16cbdc%3a874f8ea2%3ac172ae1e%3a19620875%3a9cdfc6e7%3ae330518b%3ac8618e41%3ae4f8f289%3a490a9d4e%3abd8f85e4%3a68f76a79%3a2a2fc429%3a7165f74%3ab7778d6c%3a52af31a4, line 13675 character 8