.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to use a object from the cache in a mvc View

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :ASP.Net

I am working with asp.net mvc and i am trying to get acces to a object that is in the cache.
In the Application_Start() of Global.asax.cs i create and store an object in the cache like this:

Translator translator = new Translator();
HttpContext.Current.Cache.Insert("Translator", translator, null, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration);

Translator holds a dictionary with translations.

Now i want acces to this object from the cache to use functions and get values from the dictionary.

How can i do this?

I know i can acces it like this HttpContext.Current.Cache.Get("Translator") or Cache.Get("Translator") in the views
But how can i use the functions of the object ? The meaning of the cache is to have a object that is accesable througout the webapp right ?

Do i have to make an object and asses the value of the Cache.Get("Translator") to it, so i can use the functions or is there another solution?

View Complete Post

More Related Resource Links

How to Cache System.Collection.Generic.List object


I need to cache System.Collection.Generic.List object with expiration time

var Root = from feed in feedhotel.Descendants(ota + "HotelContent")
                           where (feed.Attribute("HotelCode") != null)
                           select new xmlhotel()




return Root.ToList();

Is it possible to cache Root.ToList() for some time....

Object Cache: The super user account utilized by the cache is not configured. This can increase the

Hi im having the following error in the windows event viewer Object Cache: The super user account utilized by the cache is not configured. This can increase the number of cache misses, which causes the page requests to consume unneccesary system resources.  To configure the account use the following command 'stsadm -o setproperty -propertyname portalsuperuseraccount -propertyvalue account -url webappurl'. The account should be any account that has Full Control access to the SharePoint databases but is not an application pool account.  Additional Data:  Current default super user account: SHAREPOINT\system after this the computer starts working slowly and slowly The account that the log shows is the aplication pool account of the first site collection I created   I followed the instrucctions in this link: http://technet.microsoft.com/en-us/library/ff758656.aspx I set new accounts to the superuser and super reader I also tried using the same account that the first error showed has superuser and super reader However  I always get this error when I try to access the Site Collection after performing this The user does not exist or is not unique.<nativehr>0x81020054</nativehr><nativestack></nativestack> In the sharepoint log I get this same error plus this Could not get token super user token, reverting to system account.&

View Definition for SP 2010 Client Object Model

Hello, I am looking for where in the SP Client Object Model that I would find where the View Definitions are Located. For various reasons, I am displaying in my own custom listview a list of Documents and I would like these list results to share the same look as if the user was looking at the list in SharePoint.Please note this is NOT web based, but an application. Can someone give me a hint as to how to pull a view definition? Thanks, Andrew

Object Cache set with Portal Super User accounts. Access denied to site.

I have the same issue on multiple farms. In this example i'll outline this problem for a three tier farm. SharePoint web server SharePoint Application server (hosts central admin) Sql server After installation and configuration i have created two web applications (claims based auth with NTLM). https://portal.contoso.com https://mysite.contoso.com The client connects on the URLs to the web server (1st tier). All is working correctly and they can access the portal and their mysite. The log file keeps reporting that i need to configure the user accounts for the Object Chache. So, i looked up the required steps and executed these conform mcrosoft guidelines (http://technet.microsoft.com/en-us/library/ff758656.aspx) All the steps run seccesfully. But when i connect to the URL i now get an access denied (even with the administrator who is site collection administrator) In the log file i get the following to lines when i connect to the site. Unknown SPRequest error occurred. More information: 0x80070002 Unknown SPRequest error occurred. More information: 0x80070005 I have exact the same issue on two other farms. Marc

Details View Biding Custom Object with Enum properties fields

Hello, I'm trying to bind custom object to details view. The problem is that enum property fields are not show.Is there any way to show enum property fields in details view ?I put some example code below (I do not specify any rows mappings, they are generated dynamically because different kind of objects are bound to details view):// My object public class OrderItem { public ItemKindEnum unitemizedItemKind { get { return (ItemKindEnum)this.unitemizedItemKindID; } } ... } // Details view configuration <asp:DetailsView ID="dvOperationDetails" runat="server" DefaultMode="ReadOnly" ... />

Object Cache: The super reader account utilized by the cache does not have sufficient permissions to

Hi Just created a site collection on freshly installed SP2010 server and I get this error in the even log when I created site collection ( timing could be a coincidence) Message is as bellow which does say what needs to be done but need more info on portalsuperreaderaccount account before using the suggested solution. ( Note the stsadm although) Object Cache: The super reader account utilized by the cache does not have sufficient permissions to SharePoint databases. To configure the account use the following command 'stsadm -o setproperty -propertyname portalsuperreaderaccount -propertyvalue account -url webappurl'. It should be configured to be an account that has Read access to the SharePoint databases. Additional Data: Current default super reader account: NT AUTHORITY\LOCAL SERVICE Regards Yogesh

View previous version of a file in document library using Client Object Model




Using Server-side object model, it is pretty simple to get the previous file versions. Say I wanted to view a file in its initial version, all I’d need to do is :




When using Client object model, I couldn’t any analogous method/property which would let me fetch the previous version of file.

Can somebody point me to a sample or the property which would serve my purpose?

Make several changes across postbacks to an object in EF data module and view changes before persist


Is there a way to make several changes across postbacks to an object in an Entity Framework (.net 4) data module, view the data with changes (such as in a gridview), and then user clicks save to persist to the database?

Problem in passing Json collection object from View to Action



I am trying to send json data from view to controller action.  But the issue is the data is not populating in the action parameter List<Score>.

View Model:
public class Score
   public int QuestionId { get; set; }
   public int PrevAnswerId { get; set; }
   public int CurrAnswerId { get; set; }
   public string CurrAnswerName { get; set; }

Json Data look like:
{QuestionId:1, PrevAnswerId:3,  CurrAnswerId:3,  CurrAnswerName:'Known to Broker'},
{QuestionId:2, PrevAnswerId:7,  CurrAnswerId:7,  CurrAnswerName:'Completed'},
{QuestionId:3, PrevAnswerId:10, CurrAnswerId:10, CurrAnswerName:'Report'}

On window load,  I will construct the Json object using "eval()" function and do some operation in the data before its save.

On Save Click, I will call the action through the ajax call.
        url: url,
        type: "GET",
        dataType: 'json',
        data: {score: ScoreJson},

Cache object issue


On the difference between application variable and cache object, a post in a certain forum says:"the cached object is stored in process, which means it doesn't persist if the application domain is restarted and it can't be shared between computers in a web farm. "

Anything in .NET or other alternative would allow the object to persist after the application domain is restarted and be shared between computers in a web farm?


Create a New object on an already New object view?


What is the best way to show a Create view on demand for a lookup item.

For instance, your on a Create view for a Product and you have a Combobox to select a Category, and link beside it to create a new Category. Once you click it another form appears as a popup or another window, you then create the Category and close the popup/window and then refresh the Combobox and auto select the new value.

Can someone provide such an example?



Replicate non indexed view to a table - custom sync object/


What is the best way to replicate data from a view containing a LEFT OUTER JOIN (so cannot be indexed) to a physical fact table on the subscriber in as real time a fashion as possible?

I have heard of the use of custom sync objects etc.. can anyone suggest the best way forward and any references?

Is CDC a candidate for this type of task?

Thanks in advance

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

Truly Understanding View State

This article provides a detailed understanding of the ViewState.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.

Model View Controller (MVC) for ASP.NET

Model View Controller (MVC) architectures, immediately wonder how the MVC pattern can be applied in an ASP.NET world. This article will demonstrate how the MVC pattern can be applied to an ASP.NET web application and still maintain the basic Microsoft supplied architecture.

C# Object Oriented Programming

So far in C# Essentials we have looked at the basics of programming in C# such as variable types and flow control. Although it would be possible to write a functional program using these techniques, there is much more to becoming a proficient C# programmer. C# is, above all, an object oriented programming language and as such any C# programmer will be expected to create object-oriented applications using this language.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend