Compiler Error Message: CS0118: 'System.Web.Caching.Cache' is a 'type' but is used like a 'variable'


What am I missing??????????


using
System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using com.amazon.webservices;

using System.Web.Caching;

/// <summary>

/// Summary description for AmazonWS

/// </summary>

public class AmazonWS

{

public AmazonWS()

{

}

public static DataSet AmazonToDataSet(string powersearchstring)

{

DataSet ds;

//is it in the cache?

if (Cache[powersearchstring] == null)

{

//create our query

ItemSearchResponse response = grabAmazonSearch(powersearchstring);

//Construct the dataset to store the results

ds = new DataSet();

ds.Tables.Add();

ds.Tables[0].Columns.Add("ProductName");

ds.Tables[0].Columns.Add("AuthorName");

ds.Tables[0].Columns.Add("Price");

ds.Tables[0].Columns.Add("URL");

Items info = response.Items[0];

Item[] items = info.Item;

DataRow dr;

//iterate the results adding new rows with

//the values from the search result item.

for (int i = 0; i < items.Length; i++)

{

Item item = itemsIdea [I];

dr = ds.Tables[0].NewRow();

dr["ProductName"] = item.ItemAttributes.Title;

dr["AuthorName"] = item.ItemAttributes.Author[0];

dr["Price"] = item.ItemAttributes.ListPrice;

dr["URL"] = item.DetailPageURL;

ds.Tables[0].Rows.Add(dr);

}

//add the dataset to the cache

Cache.Insert(powersearchstring, ds, null, DateTime.Now.AddHours(24), TimeSpan.Zero);

}

else

{

ds = (DataSet)Cache[powersearchstring];

}

//return the dataset

return ds;

}

private static ItemSearchResponse grabAmazonSearch(string powersearchstring)

{

ItemSearchResponse response;

AWSECommerceService aws = new AWSECommerceService();

ItemSearchRequest request = new ItemSearchRequest();

request.SearchIndex = "Books";

request.Power = powersearchstring;

request.ResponseGroup = new string[] { "Small" };

request.Sort = "salesrank";

ItemSearchRequest[] requests = new ItemSearchRequest[] { request };

ItemSearch itemSearch = new ItemSearch();

itemSearch.AssociateTag = "XXXXXXXXXXXXXXXXXXXXXXXX";

itemSearch.SubscriptionId = "XXXXXXXXXXXXXXXXXXXXXXXXX";

itemSearch.Request = requests;

response = aws.ItemSearch(itemSearch);

return response;

}

}

0
Bishi
11/2/2005 5:37:13 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

1 Replies
1592 Views

Similar Articles

[PageSpeed] 8

System.Web.Caching.Cache Implements the cache for a Web application. One instance of this class is created per application domain, and it remains valid as long as the application domain remains active. Information about an instance of this class is available through the Cache property of the HttpContext object or the Cache property of the Page object.

Since you are in your own private Class and also accessing Cache in the Static method you won't be be to get to either of the above instance with the Syntax you have used.Use HttpRuntime.Cache to get to the Cache ...

Look at my CacheManager Class at My Blog to use it as a utility class for handly Cache in your Project ...
ASP.Net Tips & Tricks - Jawad's Blog
0
JawadKhan
11/3/2005 1:30:28 AM
Reply:

Web resources about - Compiler Error Message: CS0118: 'System.Web.Caching.Cache' is a 'type' but is used like a 'variable' - asp.net.web-forms

Resources last updated: 12/21/2015 12:16:45 AM