473,508 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cant find item in server side cache

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
2 2644
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2324
by: Penny | last post by:
Hi all, I've built an online shopping cart using ASP Classic(based on a 'WebThang' tutorial). The shop cart page (with table showing customers selected items and costs) has only 3 buttons/links....
4
6560
by: Prince Kumar | last post by:
I joined a company recently and they have a java program which hangs (does nothing) after a while. This is no way consistent. It could succeed quite a few times and can fail a few other times....
3
3081
by: Jo Versmissen | last post by:
Does anyone know how a component can be cached server side. I know how to cache a component and it works, but I think this is client side caching, because it works with the current HttpContext. ...
4
6702
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
3
2932
by: Purti Malhotra | last post by:
Hi All, In our Web hosting environment we are using Virtual hosting i.e. multiple websites are on one server and multiple domains are pointing to a single website. Issue: We have two domains...
4
1790
by: Beemer Biker | last post by:
I am adding at bindtime an htmlbutton and an html dropdownlist. The idea is to select the item in the list, hit the button and my callback code uses the ID.selectedindex to act on the item that...
3
472
by: moondaddy | last post by:
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: public string...
9
2002
by: amanjsingh | last post by:
Does anyone know how to cache (or download and overwrite) a file from internet periodocally withouth using any server side script (PHP, ASP Coldfusion etc)? I want to display RSS feeds on my...
2
2133
by: arijitdas | last post by:
Hi, We have an ASP.NET 2.0 web application where we want to share few user specific data between server and client side code using cookie. We are seeing a very strange behavior that it does not...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.