लपेटें बाइट सरणी मेमोरीस्ट्रीम ऑब्जेक्ट में और एएसपी.NETs कैश में रखें।
MemoryStream ms = new MemoryStream(user.Picture.ToArray());
Guid imageGuid = new Guid();
HttpRuntime.Cache.Add(imageGuid.ToString(), ms, null,
DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
फिर कैश से बाहर लाने और इसे ग्राहक को भेजने के लिए एक हैंडलर (.ashx) का उपयोग करें।
string imageGuid = context.Request.QueryString[image];
MemoryStream ms = (MemoryStream)HttpRuntime.Cache[imageGuid];
// configure context.Response with appropriate content type and cache settings
// ** Edit **
// It seems I need to be more explicit with regard to the above comment:-
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetLastModified(DateTime.UtcNow);
context.Response.Cache.SetExpires(DateTime.UtcNow.AddHours(2);
context.Response.Cache.SetMaxAge(TimeSpan.FromHours(2));
context.Response.Cache.SetValidUntilExpires(true);
ms.WriteTo(context.Response.OutputStream);
अब आप मेमोरीस्ट्रीम को कैश से छोड़ सकते हैं।
HttpRuntime.Cache.Remove(imageGuid);
क्या आप छवि डेटा को फ़ाइल के रूप में स्टोर नहीं कर सकते? – AnthonyWJones
यह पहला मार्ग था, लेकिन डेटाबेस में छवि को स्टोर करना पसंदीदा समाधान था। (मेरे सिर के ऊपर) तो मुझे स्थिति से सबसे अच्छा बनाना है। – markoo
सभी की मदद के लिए धन्यवाद। त्वरित और अंतर्दृष्टि जवाब। – markoo