473,586 Members | 2,754 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.Cac he,
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(Descr iption = "Get ticket for web page"),
SoapHeader("Cre dentials")]
public string GetWebPageTicke t(string CurrentObject)
{
Guid CacheID = Guid.NewGuid();
SessionData obj = new SessionData();
obj.UserID = 1;// _credentials.Us erID;
obj.CurrentObje ct = CurrentObject;
HttpRuntime.Cac he.Insert(Cache ID.ToString(), obj, null,
DateTime.Now.Ad dMinutes(2), System.Web.Cach ing.Cache.NoSli dingExpiration) ;
//HttpRuntime.Cac he.Add(CacheID. ToString(), obj, null,
DateTime.Now.Ad dSeconds(60), TimeSpan.Zero,
System.Web.Cach ing.CacheItemPr iority.Default, null);
return CacheID.ToStrin g();
}
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(o bject sender, EventArgs e)
{
eVIPNow.eVIPNow _Gen_DAL obj = new eVIPNow.eVIPNow _Gen_DAL();
// GetWebPageTicke t calls the WS and returns the GUID
string str = obj.GetWebPageT icket("xyz");
string url = ConfigurationMa nager.AppSettin gs["HelpPath"] +
"app/SuggestionLog.a spx?Param=" + str;
// This is where we call the aspx page
System.Diagnost ics.Process.Sta rt(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)Ht tpRuntime.Cache[param];

where param is the GUID string value. this code returns null and
HttpRuntime.Cac he 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*******@newsg roup.nospam
May 17 '07 #1
2 2663
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*******@news group.nospamwro te in message
news:O7******** ******@TK2MSFTN GP06.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.Cac he, 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(Descr iption = "Get ticket for web page"),
SoapHeader("Cre dentials")]
public string GetWebPageTicke t(string CurrentObject)
{
Guid CacheID = Guid.NewGuid();
SessionData obj = new SessionData();
obj.UserID = 1;// _credentials.Us erID;
obj.CurrentObje ct = CurrentObject;
HttpRuntime.Cac he.Insert(Cache ID.ToString(), obj, null,
DateTime.Now.Ad dMinutes(2), System.Web.Cach ing.Cache.NoSli dingExpiration) ;
//HttpRuntime.Cac he.Add(CacheID. ToString(), obj, null,
DateTime.Now.Ad dSeconds(60), TimeSpan.Zero,
System.Web.Cach ing.CacheItemPr iority.Default, null);
return CacheID.ToStrin g();
}
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(o bject sender, EventArgs e)
{
eVIPNow.eVIPNow _Gen_DAL obj = new eVIPNow.eVIPNow _Gen_DAL();
// GetWebPageTicke t calls the WS and returns the GUID
string str = obj.GetWebPageT icket("xyz");
string url = ConfigurationMa nager.AppSettin gs["HelpPath"] +
"app/SuggestionLog.a spx?Param=" + str;
// This is where we call the aspx page
System.Diagnost ics.Process.Sta rt(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)Ht tpRuntime.Cache[param];

where param is the GUID string value. this code returns null and
HttpRuntime.Cac he 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*******@newsg roup.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*******@news group.nospamwro te in message
news:eh******** ********@TK2MSF TNGP05.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*******@news group.nospamwro te in message
news:O7******** ******@TK2MSFTN GP06.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
inappropriatel y 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.Ca che, 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(Descr iption = "Get ticket for web page"),
SoapHeader("Cr edentials")]
public string GetWebPageTicke t(string CurrentObject)
{
Guid CacheID = Guid.NewGuid();
SessionData obj = new SessionData();
obj.UserID = 1;// _credentials.Us erID;
obj.CurrentObje ct = CurrentObject;
HttpRuntime.Cac he.Insert(Cache ID.ToString(), obj, null,
DateTime.Now.A ddMinutes(2),
System.Web.Cac hing.Cache.NoSl idingExpiration );
//HttpRuntime.Cac he.Add(CacheID. ToString(), obj, null,
DateTime.Now.A ddSeconds(60), TimeSpan.Zero,
System.Web.Cac hing.CacheItemP riority.Default , null);
return CacheID.ToStrin g();
}
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(o bject sender, EventArgs e)
{
eVIPNow.eVIPNow _Gen_DAL obj = new eVIPNow.eVIPNow _Gen_DAL();
// GetWebPageTicke t calls the WS and returns the GUID
string str = obj.GetWebPageT icket("xyz");
string url = ConfigurationMa nager.AppSettin gs["HelpPath"] +
"app/SuggestionLog.a spx?Param=" + str;
// This is where we call the aspx page
System.Diagnost ics.Process.Sta rt(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)Ht tpRuntime.Cache[param];

where param is the GUID string value. this code returns null and
HttpRuntime.Ca che 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*******@newsg roup.nospam


May 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2330
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. 1: Back to Shop: Uses 'javascript:history.go(-1)' to go to previous page. 2: Remove Item(one next to each item in cart): Clears the selected...
4
6574
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. There is no consistency when it fails. Could anyone here shed some light on how to debug/resolve the issue. I guess IBM looked at the issue and were...
3
3090
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. .... Cache cache = HttpContext.Current.Cache; Table table; // Get the table from the cache table = (Table) cache.Get("myCacheKey");
4
6716
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 code ?? thank you Pedro Leite From Portugal ------------------------------------
3
2938
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 say “www.Test1.com” and “www.Test2.com” pointing to a single website. Website content is located onto UNCPath i.e. remote location. Domain...
4
1792
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 was selected. I tested it all out by dropping a button and a DDL on a form. Worked ok. Then I wrote the code that automatically added the the button...
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 GetWebPageTicket(string CurrentObject) { Guid CacheID = Guid.NewGuid(); Methods.ErrLog(CacheID.ToString(), false, false);
9
2011
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 website from CNET using their RSS XML file but I do not know how to repeatedly download the file to keep the latest version on my server. Thanks AJ
2
2136
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 work consistently. Sometimes we are getting the latest value set from server in client script, sometimes were are getting a wrong (previously set...
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
1
7954
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8215
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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 we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.