Cant find item in server side cache

M

moondaddy

This code is all executed on my dev machine running winXP sp2 and VS2005.

I have a winforms 2.0 app that calls a web service wich caches a GUID for a
short time like this:

[WebMethod(Description = "Get ticket for web page"),
SoapHeader("Credentials")]
public string GetWebPageTicket(string CurrentObject)
{
Guid CacheID = Guid.NewGuid();
Methods.ErrLog(CacheID.ToString(), false, false);
SessionData obj = new SessionData();
obj.UserID = 1;// _credentials.UserID;
obj.CurrentObject = CurrentObject;
HttpRuntime.Cache.Insert(CacheID.ToString(), obj, null,
DateTime.Now.AddMinutes(2), System.Web.Caching.Cache.NoSlidingExpiration);
//HttpRuntime.Cache.Add(CacheID.ToString(), obj, null,
DateTime.Now.AddSeconds(60), TimeSpan.Zero,
System.Web.Caching.CacheItemPriority.Default, null);
return CacheID.ToString();
}


This web service returns the GUID back to the client where the client then
calls a aspx page and passes the GUID in as a parameter like this:

private void button1_Click(object sender, EventArgs e)
{
eVIPNow.eVIPNow_Gen_DAL obj = new eVIPNow.eVIPNow_Gen_DAL();
// GetWebPageTicket calls the WS and returns the GUID
string str = obj.GetWebPageTicket("xyz");
string url = ConfigurationManager.AppSettings["HelpPath"] +
"app/SuggestionLog.aspx?Param=" + str;
// This is where we call the aspx page
System.Diagnostics.Process.Start(url);
}


Now in the aspx page I run this code in and effort to find the cached GUID
from the WS:
// See if we can find the param in our cache
_sessionData = (SessionData)HttpRuntime.Cache[param];

where param is the GUID string value. this code returns null and
HttpRuntime.Cache has zero items in it. its almost like the WS and aspx
page are hitting 2 different instances of IIS.

I have very similar code running in another app which uses vb 1.1 and it
works good.

Any ideas why this doesnt work?

Thanks.
 
K

Kevin Spencer

Unless your web service and your ASP.Net application are in the same
application space in IIS, they will not share cache. IIS can host many
separate applications. Therefore, it your web service is in its own
application, separate from the ASP.Net application, only the web service
will be able to fetch the data from its cache.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
M

moondaddy

This has worked fine using asp.net 1.1 on the same machine. The asmx and
aspx page are in the same application which is a asp.net 2.0 website,
therefore, they should be in the same application space. any other ideas?

Thanks


Kevin Spencer said:
Unless your web service and your ASP.Net application are in the same
application space in IIS, they will not share cache. IIS can host many
separate applications. Therefore, it your web service is in its own
application, separate from the ASP.Net application, only the web service
will be able to fetch the data from its cache.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

moondaddy said:
This code is all executed on my dev machine running winXP sp2 and VS2005.

I have a winforms 2.0 app that calls a web service wich caches a GUID for
a short time like this:

[WebMethod(Description = "Get ticket for web page"),
SoapHeader("Credentials")]
public string GetWebPageTicket(string CurrentObject)
{
Guid CacheID = Guid.NewGuid();
Methods.ErrLog(CacheID.ToString(), false, false);
SessionData obj = new SessionData();
obj.UserID = 1;// _credentials.UserID;
obj.CurrentObject = CurrentObject;
HttpRuntime.Cache.Insert(CacheID.ToString(), obj, null,
DateTime.Now.AddMinutes(2),
System.Web.Caching.Cache.NoSlidingExpiration);
//HttpRuntime.Cache.Add(CacheID.ToString(), obj, null,
DateTime.Now.AddSeconds(60), TimeSpan.Zero,
System.Web.Caching.CacheItemPriority.Default, null);
return CacheID.ToString();
}


This web service returns the GUID back to the client where the client
then calls a aspx page and passes the GUID in as a parameter like this:

private void button1_Click(object sender, EventArgs e)
{
eVIPNow.eVIPNow_Gen_DAL obj = new eVIPNow.eVIPNow_Gen_DAL();
// GetWebPageTicket calls the WS and returns the GUID
string str = obj.GetWebPageTicket("xyz");
string url = ConfigurationManager.AppSettings["HelpPath"] +
"app/SuggestionLog.aspx?Param=" + str;
// This is where we call the aspx page
System.Diagnostics.Process.Start(url);
}


Now in the aspx page I run this code in and effort to find the cached
GUID from the WS:
// See if we can find the param in our cache
_sessionData = (SessionData)HttpRuntime.Cache[param];

where param is the GUID string value. this code returns null and
HttpRuntime.Cache has zero items in it. its almost like the WS and aspx
page are hitting 2 different instances of IIS.

I have very similar code running in another app which uses vb 1.1 and it
works good.

Any ideas why this doesnt work?

Thanks.
 
M

moondaddy

Please disregard this thread. I figured out the problem as it was a classic
'Stupid User Error'.

When coding the URL to the aspx page I copied the url when I first ran and
tested the page on its own. this url looked something like this:

http://localhost:2100/bla bla bla...

Note the ":2100" which is how VS2005 or asp.net interpreted it.

Then I used the url for web service when it was originally created which was
something like this:

http://localhost/WebAppName/bla bla bla

it used the web app name instead of the 2100. So the web service and aspx
page really were running in different instances of the web app. I just
assumed that the urls created by VS would all work together. when converted
the 2100 to the web app name (the folder the web app lives in) all worked
fine.

Sorry to anyone who read through this thread.




moondaddy said:
This code is all executed on my dev machine running winXP sp2 and VS2005.

I have a winforms 2.0 app that calls a web service wich caches a GUID for
a short time like this:

[WebMethod(Description = "Get ticket for web page"),
SoapHeader("Credentials")]
public string GetWebPageTicket(string CurrentObject)
{
Guid CacheID = Guid.NewGuid();
Methods.ErrLog(CacheID.ToString(), false, false);
SessionData obj = new SessionData();
obj.UserID = 1;// _credentials.UserID;
obj.CurrentObject = CurrentObject;
HttpRuntime.Cache.Insert(CacheID.ToString(), obj, null,
DateTime.Now.AddMinutes(2), System.Web.Caching.Cache.NoSlidingExpiration);
//HttpRuntime.Cache.Add(CacheID.ToString(), obj, null,
DateTime.Now.AddSeconds(60), TimeSpan.Zero,
System.Web.Caching.CacheItemPriority.Default, null);
return CacheID.ToString();
}


This web service returns the GUID back to the client where the client then
calls a aspx page and passes the GUID in as a parameter like this:

private void button1_Click(object sender, EventArgs e)
{
eVIPNow.eVIPNow_Gen_DAL obj = new eVIPNow.eVIPNow_Gen_DAL();
// GetWebPageTicket calls the WS and returns the GUID
string str = obj.GetWebPageTicket("xyz");
string url = ConfigurationManager.AppSettings["HelpPath"] +
"app/SuggestionLog.aspx?Param=" + str;
// This is where we call the aspx page
System.Diagnostics.Process.Start(url);
}


Now in the aspx page I run this code in and effort to find the cached GUID
from the WS:
// See if we can find the param in our cache
_sessionData = (SessionData)HttpRuntime.Cache[param];

where param is the GUID string value. this code returns null and
HttpRuntime.Cache has zero items in it. its almost like the WS and aspx
page are hitting 2 different instances of IIS.

I have very similar code running in another app which uses vb 1.1 and it
works good.

Any ideas why this doesnt work?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top