Click here to Skip to main content
15,916,371 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: .NET, Personal Web Servers and XP Pin
NickLewis7-Jan-02 11:19
NickLewis7-Jan-02 11:19 
QuestionHow can "I" use .NET? Pin
shypht5-Jan-02 20:07
shypht5-Jan-02 20:07 
AnswerRe: How can "I" use .NET? Pin
James T. Johnson7-Jan-02 10:49
James T. Johnson7-Jan-02 10:49 
AnswerRe: How can "I" use .NET? Pin
Nemanja Trifunovic7-Jan-02 10:53
Nemanja Trifunovic7-Jan-02 10:53 
GeneralRe: How can "I" use .NET? Pin
James T. Johnson7-Jan-02 11:02
James T. Johnson7-Jan-02 11:02 
GeneralRe: How can "I" use .NET? Pin
shypht7-Jan-02 13:19
shypht7-Jan-02 13:19 
GeneralParser Error Pin
Orkun GEDiK5-Jan-02 11:55
Orkun GEDiK5-Jan-02 11:55 
GeneralCacheItemRemovedCallback Problems Pin
Tim Bajz3-Jan-02 3:21
Tim Bajz3-Jan-02 3:21 
Guys,

I am having problems with the use of the CacheItemRemovedCallback event within an ASP.NET/C# website I am building. The below code is from my global.aspx file. The code loads XML/XSL objects into the Cache for later use. I also create a Cache dependency so should any files change which my XML/XSL objects use, the Cache is updated automatically. The code works only when something is removed from the Cache by another aspx file, since the code correctly identifies the HttpContext. However, when one of my files is changed and the RemovedCallback() function is fired, for some reason the Context and the HttpContext are both null. As such my code never has a chance to update the Cache again. Rather it exists "without an error" as soon as I try to use Cache.Insert. Does anyone know if this is a bug in Beta 2, or am I missing something, like the use of a special Context object?

Any help greatly appreciated..........

Cheers,
Tim.

<%@ Import Namespace="System.Xml.Xsl" %>
<%@ Import Namespace="System.Xml.XPath" %>
<%@ Import Namespace="System.Web.Caching" %>
<%@ Import Namespace="CommerceEngine.Common" %>



private static CacheItemRemovedCallback onRemove = null;
private XPathDocument CommerceListXmlObj;
private XslTransform CommerceListXslObj;

public void Application_OnStart()
{
ApplicationConfiguration.OnApplicationStart(Context.Server.MapPath( Context.Request.ApplicationPath ));
onRemove = new CacheItemRemovedCallback(this.RemovedCallback);

CommerceListXmlObj = new XPathDocument(CommerceEngineConfiguration.CommerceListXmlFilePath);
HttpContext.Current.Cache.Insert("CommerceListXmlObj", CommerceListXmlObj, new CacheDependency (CommerceEngineConfiguration.CommerceListXmlFilePath), DateTime.Now.AddHours(1), TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Slow, onRemove );

CommerceListXslObj = new XslTransform();
CommerceListXslObj.Load(CommerceEngineConfiguration.CommerceListXslFilePath);
HttpContext.Current.Cache.Insert("CommerceListXslObj", CommerceListXslObj, new CacheDependency(CommerceEngineConfiguration.CommerceListXslFilePath), DateTime.Now.AddHours(1), TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Slow, onRemove );
}

public void RemovedCallback(String k, Object v, CacheItemRemovedReason r)
{
switch(k)
{
case "CommerceListXmlObj" :

CommerceListXmlObj = new XPathDocument(CommerceEngineConfiguration.CommerceListXmlFilePath);
HttpContext.Current.Cache.Insert("CommerceListXmlObj", CommerceListXmlObj, new CacheDependency(CommerceEngineConfiguration.CommerceListXmlFilePath), DateTime.Now.AddHours(1), TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Slow, onRemove );
break;
}
}


GeneralASP.NET Pin
Matt.W.2-Jan-02 16:14
Matt.W.2-Jan-02 16:14 
GeneralRe: ASP.NET Pin
James T. Johnson3-Jan-02 6:38
James T. Johnson3-Jan-02 6:38 
GeneralRe: ASP.NET Pin
Matt.W.3-Jan-02 12:02
Matt.W.3-Jan-02 12:02 
GeneralRe: ASP.NET Pin
4-Jan-02 7:16
suss4-Jan-02 7:16 
GeneralRe: ASP.NET Pin
Matt.W.6-Jan-02 19:34
Matt.W.6-Jan-02 19:34 
GeneralRe: ASP.NET Pin
21-Jan-02 10:36
suss21-Jan-02 10:36 
GeneralServer Error in '/myaspx' Application Pin
Orkun GEDiK27-Dec-01 8:55
Orkun GEDiK27-Dec-01 8:55 
QuestionWhat is .NET???? Pin
Jon Newman20-Dec-01 8:18
Jon Newman20-Dec-01 8:18 
AnswerRe: What is .NET???? Pin
Fazlul Kabir20-Dec-01 8:25
Fazlul Kabir20-Dec-01 8:25 
QuestionDefining assignment operator on a managed C++ class? Pin
DVryce19-Dec-01 3:30
DVryce19-Dec-01 3:30 
General.NET assembly question Pin
C. Kapturek19-Dec-01 1:01
C. Kapturek19-Dec-01 1:01 
GeneralRe: .NET assembly question Pin
C. Kapturek19-Dec-01 3:01
C. Kapturek19-Dec-01 3:01 
GeneralConverting .NET String to something usable by old unsafe C/C++ Code Pin
DVryce17-Dec-01 7:39
DVryce17-Dec-01 7:39 
GeneralRe: Converting .NET String to something usable by old unsafe C/C++ Code Pin
James T. Johnson17-Dec-01 8:05
James T. Johnson17-Dec-01 8:05 
GeneralRe: Converting .NET String to something usable by old unsafe C/C++ Code Pin
DVryce17-Dec-01 9:38
DVryce17-Dec-01 9:38 
GeneralRe: Converting .NET String to something usable by old unsafe C/C++ Code Pin
James T. Johnson17-Dec-01 16:15
James T. Johnson17-Dec-01 16:15 
GeneralBig time help needed! Pin
GaryGa14-Dec-01 21:23
GaryGa14-Dec-01 21:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.