By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,563 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,563 IT Pros & Developers. It's quick & easy.

Cant find item in server side cache

P: n/a
I had to repost this because I had to update and change my msdn alias. I
will re-ask the question and clarify a few things that were not clear
before.

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

I'm using a c# 2.0 winforms app which talks to a c#2.0 asp.net app that also
contains 1 web service. Note: the webpage and web service are located side
by side in the same web app.

Scenario: the winform needs to call up a web page that has confidential
data that only the person logged into the winform is allowed to see. I
don't want to force the user to log into the win app and then log into the
web app too. so what I do is:
1) the winform calls a web service which generates a GUID and puts it into
server side cache for about 10 seconds (2 min while I'm testing and
debugging). the web service also caches the User ID and some other data
passed in from the winform.
2) the web service returns the GUID back to the winform via the WS return
value.
3) the winform calls the aspx page and passes the GUID in the url as a
parameter
4) the aspx page uses the GUID param as a key to find the cached data from
the related WS call.
5) if the cache is not found (call took too long or someone is
inappropriately call the page), its redirected to a page describing the
problem.
6) if the cache is found, the aspx page creates a serve side session object
to contain the User ID and other related data and the page is then returned
to the winform user.

This works great in a vb.net 1.1 app I have. I created this new c# 2.0 app
and used all the same code converted from vb.net 1.1 to c#2.0 but the aspx
page can not find the cached object. when I look in the HttpRuntime.Cache,
the item count is zero. However, to test this and make sure the code works
OK, I created a test aspx page which calls the web service and returns the
GUID. then I click on a 2nd button in the test page and it calls the
correct page passing in the GUID as a param just as the winform does and it
will find the cached object. all the code runs fine, its just that when
called from the winform, the cache cant be found. its like the WS called
from the winform is running in a different app from the web page called from
the same winform (although the aspx and asmx pages are both part of the same
app).

Here's my code:


I have a winforms 2.0 app that calls a web service which 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();
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 doesn't work?

Thanks.



--
mo*******@newsgroup.nospam
May 17 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I still need help on this one, but I did find something of interest. I
suspected that the aspx page could not find the item cached because maybe
the aspx page was generated in a different instance of the web app from the
instance the web service was running in (although they are part of the same
web app). I posted the app on a remote server and things seem to work fine,
so I suspect that the problem might be the way asp.net 2.0 works on a
development machine. Like I said earlier, this exact same type of process
works OK on my dev machine using asp.net 1.1.

Saying all of this, I would still like to resolve this issue on my dev
machine as I will be contining development using this process and its
dificult to build out when it doesnt work in the dev enviroment.

Thanks.


"moondaddy" <mo*******@newsgroup.nospamwrote in message
news:O7**************@TK2MSFTNGP06.phx.gbl...
>I had to repost this because I had to update and change my msdn alias. I
will re-ask the question and clarify a few things that were not clear
before.

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

I'm using a c# 2.0 winforms app which talks to a c#2.0 asp.net app that
also contains 1 web service. Note: the webpage and web service are
located side by side in the same web app.

Scenario: the winform needs to call up a web page that has confidential
data that only the person logged into the winform is allowed to see. I
don't want to force the user to log into the win app and then log into the
web app too. so what I do is:
1) the winform calls a web service which generates a GUID and puts it into
server side cache for about 10 seconds (2 min while I'm testing and
debugging). the web service also caches the User ID and some other data
passed in from the winform.
2) the web service returns the GUID back to the winform via the WS return
value.
3) the winform calls the aspx page and passes the GUID in the url as a
parameter
4) the aspx page uses the GUID param as a key to find the cached data
from the related WS call.
5) if the cache is not found (call took too long or someone is
inappropriately call the page), its redirected to a page describing the
problem.
6) if the cache is found, the aspx page creates a serve side session
object to contain the User ID and other related data and the page is then
returned to the winform user.

This works great in a vb.net 1.1 app I have. I created this new c# 2.0
app and used all the same code converted from vb.net 1.1 to c#2.0 but the
aspx page can not find the cached object. when I look in the
HttpRuntime.Cache, the item count is zero. However, to test this and make
sure the code works OK, I created a test aspx page which calls the web
service and returns the GUID. then I click on a 2nd button in the test
page and it calls the correct page passing in the GUID as a param just as
the winform does and it will find the cached object. all the code runs
fine, its just that when called from the winform, the cache cant be found.
its like the WS called from the winform is running in a different app from
the web page called from the same winform (although the aspx and asmx
pages are both part of the same app).

Here's my code:


I have a winforms 2.0 app that calls a web service which 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();
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 doesn't work?

Thanks.



--
mo*******@newsgroup.nospam

May 18 '07 #2

P: n/a
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" <mo*******@newsgroup.nospamwrote in message
news:eh****************@TK2MSFTNGP05.phx.gbl...
>I still need help on this one, but I did find something of interest. I
suspected that the aspx page could not find the item cached because maybe
the aspx page was generated in a different instance of the web app from the
instance the web service was running in (although they are part of the same
web app). I posted the app on a remote server and things seem to work
fine, so I suspect that the problem might be the way asp.net 2.0 works on a
development machine. Like I said earlier, this exact same type of process
works OK on my dev machine using asp.net 1.1.

Saying all of this, I would still like to resolve this issue on my dev
machine as I will be contining development using this process and its
dificult to build out when it doesnt work in the dev enviroment.

Thanks.


"moondaddy" <mo*******@newsgroup.nospamwrote in message
news:O7**************@TK2MSFTNGP06.phx.gbl...
>>I had to repost this because I had to update and change my msdn alias. I
will re-ask the question and clarify a few things that were not clear
before.

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

I'm using a c# 2.0 winforms app which talks to a c#2.0 asp.net app that
also contains 1 web service. Note: the webpage and web service are
located side by side in the same web app.

Scenario: the winform needs to call up a web page that has confidential
data that only the person logged into the winform is allowed to see. I
don't want to force the user to log into the win app and then log into
the web app too. so what I do is:
1) the winform calls a web service which generates a GUID and puts it
into server side cache for about 10 seconds (2 min while I'm testing and
debugging). the web service also caches the User ID and some other data
passed in from the winform.
2) the web service returns the GUID back to the winform via the WS
return value.
3) the winform calls the aspx page and passes the GUID in the url as a
parameter
4) the aspx page uses the GUID param as a key to find the cached data
from the related WS call.
5) if the cache is not found (call took too long or someone is
inappropriately call the page), its redirected to a page describing the
problem.
6) if the cache is found, the aspx page creates a serve side session
object to contain the User ID and other related data and the page is then
returned to the winform user.

This works great in a vb.net 1.1 app I have. I created this new c# 2.0
app and used all the same code converted from vb.net 1.1 to c#2.0 but the
aspx page can not find the cached object. when I look in the
HttpRuntime.Cache, the item count is zero. However, to test this and
make sure the code works OK, I created a test aspx page which calls the
web service and returns the GUID. then I click on a 2nd button in the
test page and it calls the correct page passing in the GUID as a param
just as the winform does and it will find the cached object. all the
code runs fine, its just that when called from the winform, the cache
cant be found. its like the WS called from the winform is running in a
different app from the web page called from the same winform (although
the aspx and asmx pages are both part of the same app).

Here's my code:


I have a winforms 2.0 app that calls a web service which 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();
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 doesn't work?

Thanks.



--
mo*******@newsgroup.nospam


May 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.