jeudi 7 avril 2016

asp.net mvc Save uploaded files in cache

How can i save uploaded files in cache? First of all i placed my uploaded in form files into a cache, but when im trying get it, it is empty, why? ASP.NET MVC project; Code:

private IEnumerable<HttpPostedFileBase> _cachedFiles
                {
                    get
                    {
                        return System.Web.HttpContext.Current.Cache["UploadingFiles"] as IEnumerable<HttpPostedFileBase>;
                    }
                    set
                    {
                        System.Web.HttpContext.Current.Cache["UploadingFiles"] = value;
                    }
                }

     [HttpPost]
            public ActionResult SetInCache(IEnumerable<HttpPostedFileBase PostedFiles)
            {
                _cachedFiles = PostedFiles;
                return null;
    }



          public ActionResult GetFromCache(
                        {
                          var files = _cachedFiles;
                       // here my files are empty!! collection with null
                        }




Aucun commentaire:

Enregistrer un commentaire