带有异步动作视图的城堡单轨铁路渲染异常



我正在尝试在单轨网中使用异步操作,但是当视图呈现时,我会得到nullReference异常,也使用emtpy View File进行了测试。

我还尝试在enduploadtags中调用Renderview(uploadTags.vm")。当我在enduploadtag中调用RenderText(S)时,我没有例外。

stacktrace:

   [NullReferenceException: Object reference not set to an instance of an object.]
   Castle.MonoRail.Framework.Services.DefaultCacheProvider.Get(String key) +163
   Castle.MonoRail.Framework.Views.NVelocity.CustomResourceManager.GetResource(String resourceName, ResourceType resourceType, String encoding) +68
   NVelocity.Runtime.RuntimeInstance.GetTemplate(String name, String encoding) +57
   NVelocity.Runtime.RuntimeInstance.GetTemplate(String name) +82
   NVelocity.App.VelocityEngine.GetTemplate(String name) +47
   Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine.Process(String viewName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext) +564
   Castle.MonoRail.Framework.Services.DefaultViewEngineManager.Process(String templateName, TextWriter output, IEngineContext context, IController controller, IControllerContext controllerContext) +237
   Castle.MonoRail.Framework.Controller.ProcessView() +146
   Castle.MonoRail.Framework.Controller.EndProcess() +1579
   Castle.MonoRail.Framework.BaseAsyncHttpHandler.EndProcessRequest(IAsyncResult result) +141
[MonoRailException: Error processing MonoRail request. Action uploadtags on asyncController vendor]
   Castle.MonoRail.Framework.BaseAsyncHttpHandler.EndProcessRequest(IAsyncResult result) +461
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +86

这是我的测试代码:

        private Output output;
        public delegate string Output();
        private string DoNothing()
        {
            return "nothing";
        }
        private string Upload()
        {
            return "upload";
        }
        public IAsyncResult BeginUploadTags(HttpPostedFile xmlFile, Boolean doUpload)
        {
            if (IsPost)
            {
                output = Upload;
                return output.BeginInvoke(ControllerContext.Async.Callback, null);
            }
            output = DoNothing;
            return output.BeginInvoke(ControllerContext.Async.Callback, null);
        }
        public void EndUploadTags()
        {
            var s = output.EndInvoke(ControllerContext.Async.Result);
            PropertyBag["logging"] = s;
        }

这是单轨旧版本中的错误。它在Monorail 2.1 RC中起作用,但在我刚刚尝试过的旧版本中不使用,我得到了相同的无效例外。

这就是修订5688在颠覆中的样子,这就是NullReferenceException的来源。代码不再使用HttpContext进行缓存。

public object Get(String key)
{
    if (logger.IsDebugEnabled)
    {
        logger.DebugFormat("Getting entry with key {0}", key);
    }
    return GetCurrentContext().Cache.Get(key);
}
private static HttpContext GetCurrentContext()
{
    return HttpContext.Current;
}

相关内容

  • 没有找到相关文章

最新更新