C# - Optimal Way To Cache Time Of Day Description?

Mar 30, 2011

What is the best method to cache the following? I am creating an intranet web application template that will display the message, e.g., Good Morning, Justin Satyr! near the top of my master page header. Obviously, I will have to determine whether to show Morning, Afternoon or Evening. For clarity, my code is below:

string partOfDay;
var hours = DateTime.Now.Hour;
if (hours > 16)
{
partOfDay = "evening";
}
else if (hours > 11)
{
partOfDay = "afternoon";
}
else
{
partOfDay = "morning";
}

I do not want to re-determine this on each page load because that seems moderately redundant and because I have to poll a SQL server to retrieve the user's full name. What is the best way to cache this nformation? If I cache it for the length of the session, then if the user begins using the application at 11:00 AM and finishes at 3:00 PM, it will still say Good Morning. Is the best thing to do simply re-determine the M/A/E word each page load and cache the person's full name for the session? Or is there a better way?

View 3 Replies


Similar Messages:

Web Forms :: Description Box - Modify The Description Not To Be In A Straight Line

Jan 30, 2011

<asp:FormView ID="FormView1" runat="server" DataKeyNames="productnum"
DataSourceID="EDS_Product">
<ItemTemplate>
<div class="ContentHead"><%# Eval("name") %></div><br />
<table border="0">
<tr><td style="vertical-align: top;">
<img src='images/big/<%# Eval("image") %>' border="0" alt='<%# Eval("name") %>' /></td>
<td style="vertical-align: top"><%# Eval("description") %>
<br /><br /><br /></td></tr></table>
<span class="price"><b>Your Price:</b> <%# Eval("price", "{0:c}")%><br /><span class="number"><b>Number:</b> <%# Eval("number") %>
</span><br /><a href='AddToCart.aspx?productnum=<%# Eval("productnum") %>'>
<span class="ProductListItem"><b>Add To Cart<b></font></span></a>
</ItemTemplate>
</asp:FormView

this is from the product details page and the description goes in a straight line always - i want to make the description a box and have lenght of 30 characters every line -- i want to modify the description not to be in a straight line

View 3 Replies

VS 2005 - Clearing Cache All The Time?

Jun 22, 2011

I have a new ASP.Net web project and every time I change anything in the CSS file I need to delete temp internet files before I can see my changes?

View 8 Replies

Xml File Opened And Read Each And Every Time Any Way To Cache It?

Mar 3, 2011

I have a navigation on my site that retrieves it's links from xml file..Does asp do this everytime a link is clicked on my site..I'm using a master page and the navigation code within the master page is below..So is the xml file opened and read each and every time? any way to cache it or something.below is my code

[Code]...

View 5 Replies

System.Web.Caching.Cache Doesn't Seem To Refresh Itself On Time

Jan 27, 2011

I am using System.Web.Caching.Cache in an assembly used by my website.

I have set some key expiration (absolute expiration) to be 10 seconds (just for debugging).

I have also set a callback upon key removal.

The problem is that I see that the cache is getting refreshed after something like 20 seconds and not 10.

I am using HttpRuntime.Cache for this.

I would like to show a code sample, which can shed more light:

[code]....

What could be the problem ?

View 2 Replies

Cache Sharing - Between Different Users Accessing The Site On Different Computer At The Same Time

Jul 21, 2010

I have an ASP.Net 4.0 web application which very frequently loads data from the database and does heavy calculations on it. I want to cache this loaded and prepared data in a central cache that can be accessed by every user and computer who uses the application.

Simple use-case:

User 1 accesses webpage, cache is empty, data is loaded/calculated, data is cached
User 2 accesses webpage, cache contains data, data loaded from cache
User 3 accesses webpage, cache contains data, data loaded from cache
User 1 reloads webpage, cache contains data, data loaded from cache
Cache expires
User 3 refreshes webpage, cache is empty, data is loaded/calculated, data is cached

I know that ASP.Net has a built-in cache mechanism. What I don't know is whether it can be shared between different users accessing the site on different computer at the same time. I would also like to know how the system behaves in a web farm environment.

View 3 Replies

State Management :: How To Cancel The Cache Object Within Time Elapsed

Jul 26, 2010

i have simple form which consists of 2 labels and 2 buttons, the first label will display the current time and second label will display the cached time for 2 mins which is absolute..

no w when i click on first button only current time have to get update,, and when i click on second button both current time cached time have to be updated even though the cached time of 2 mins not elapsed also.

View 4 Replies

State Management :: Create Cache Object Every Time On Access?

Aug 7, 2010

This source what i have used to create cache object.Also i have checked if "AppCache_Caption" cache object is available or not.
[Code]....
Right now i have checked and created my login page page_load event.It will create cache object every time me access the login page.What are the conditions wrong my source?My expectation, cache object creates only one time.It will not create everytime.

View 4 Replies

Web Forms :: Items Getting Removed From Cache Earlier Than Specified Expiration Time

Dec 26, 2012

I wrote this code for inserting Items in shopping cart and I expect one day Shopping Cart Items be available.

if (Cache[username] == null)
{
ShoppingCart cart = new ShoppingCart();

[Code].....

and I face another problem that I think it's related to above problem. I have a cateogry of product when I click on a category I send categoryid via querystring to another page and fetch iformation about that from database and bind them in repeater this is first line of code

<asp:Repeater ID="rpt_lookpd" runat="server" EnableViewState="false">

I found product doesn't show in second page but before there wasn't this problem.

When I removed EnableViewState="false" It worked again.

[URL]

View 1 Replies

C# - Making A Description Text - Unable To Get A Description Text From The Whole Text Which Exist In Txt Field

Feb 28, 2011

I have in my database the News Table which consist of => Id, Title, txt . I need to be able to get a description text from the whole text which exist in txt Field , but without any codes like <...> , just a pure text !! how can I do this?

View 3 Replies

Viewstate - What Is An Optimal Value For MaxPageStateFieldLength

Apr 6, 2010

In pages that have a viewstate that spans 10-15KB what would be an optimal value for

<pages maxPageStateFieldLength="">

in the web.config in order to reduce the risk of potential truncation leading to viewstate validation errors?

View 2 Replies

MVC :: Feedback On The Most Optimal Toolsets For TDD, Mocking, And IOC?

May 25, 2010

I'll be starting a complete re-write of a system in the coming weeks. I'll be using ASP.NET MVC 2.I'm still trying to determine what I should be using as far as TDD, mocking, and IOC is concerned. I was thinking:

VSTEST for writing my TDD tests (or possibly nUnit) Moq as my mocking framework (for creating doubles and fakes) Moq for IOC development Not sure exactly what the ideal setup should be and I'm continuing to research what's available. I'd like some feedback from the community on the most optimal toolsets for TDD, mocking, and IOC.

View 10 Replies

ADO.NET :: Optimal Conversion Between Database To An Object?

Aug 12, 2010

i want to know if the only way to get information from database and transform them into objects is with a datareader or with a dataadapter and them looping throw the datarows, cause i have a lot of records in the table and i have to find the fastest way to do it. (like 10,000,000 records).

View 3 Replies

AJAX :: Proper / Optimal Way To Use Updatepanel With Timer

Apr 1, 2011

If that is even the right combination of controls to use.. I have a page that will display a list of files that have been processed or processing.. its not really time sensitive, but would like for the page to refresh the gridview every say every minutelonger(not determined yet)Is that the most optimal way to accomplish this, i mean if you are on the page, i dont want you to have to hit refresh to see any new records or status changes to the existing records..

View 4 Replies

Optimal Way To Display Dynamic Data In A Grid-like Structure?

Sep 1, 2010

I have a requirement where I would not know the columns and any result set information at design-time, so I'd be generating the data-display control dynamically.What is the most suitable way to display this type of information on-the-fly in a table/grid like structure on an ASP.NET page considering the following parameters (in order of importance):

Performance
Extensibility
Usability

I know I can dynamically generate a gridview/repeater/listview control but what I'd like to understand is which option (from stated ones or any other beyond these) would be an optimal solution..S. Paging and Sorting are part of desired functionalities, but can be overlooked if the solution is overwhelming. :)

View 2 Replies

C# - Optimal Database Connection String For High Traffic Connections?

Mar 14, 2011

I just want to know, What parameters or attributes should be taken in connection string so as to handle high traffic enterprise applications? Like in general we use server, initial catalog, userid, passwd. Some times we add timeout , and in some scenario pool etc. But i don't know what attributes should i take in as my common practice apart from above.

View 3 Replies

ADO.NET :: Use The Item Description Look Up Table And Store The Item Description Id In The Items Table?

Dec 31, 2010

i have the following two questions:-

1. let say i have a table for ITEMS including (item id,item description id (FK to the ITEM Description tabe), item price,etc) and have ITEM Description look up table having (item descriptionid,item description),.

so what is better to use the ITEM DESCRIPTION look up table and store the item description id in the items table

or

to directly store the item description "Not the id" in the item table.

2. I am working on an MVC web application using LINQ, now if i want to modify the SQL server tables which i have created for example modify some of the foreign key properties will the effect be directly reflected on any new inserted or deleted records or i have to create a new LINQ to SQL class?

View 3 Replies

C# - Implement System.Web.Caching.Cache Object In A Controller To Cache Specific Query?

Mar 29, 2010

Is it correct to implement my caching object like this in my controller :

[code]....

And I Use it like this :

[code]....

View 1 Replies

Architecture :: Cache The Full List Of Objects In Http Cache On The Service Tier And Page In Memory?

Feb 25, 2011

We have a wfc layer that wraps the business classes and database access and use a client that lives on the database layer. Amongst our group we are attempting to form standards. Some want to have the client call the web method and pass the page they are requesting and the page size. Pass that to the database and then page in SQL Server use RowNum.Some want to cache the full list of objects in http cache on the service tier and page in memory. They concern here is memory use on the server.

Which would be best for a medium number of users with potentially large number of records to manage (say 30K) Is it better to cache them all in memory and work from there or page at the database as the application scales?

View 1 Replies

New-Cache Parameters For AppFabric Cache When Storing.NET Session State

Jul 28, 2010

What are the "optimal" parameters for creating an AppFabric cache when you will be storing session state in the cache? MSDN Cache-Related Commands

Powershell command line:

New-Cache [-CacheName] <String> [-Eviction <String>] [-Expirable <String>] [-Force [<SwitchParameter>]] [-NotificationsEnabled <String>] [-Secondaries <Int32>] [-TimeToLive <Int64>]

[code]...

Since I don't want my sessions to be removed unless the session has been abandoned either via code or Session Timeout...For eviction, I would think "None" and for expireable, I would think False.I have tested and calling Session.Abandon does remove the object from the cache. I have also tested to see if by extending my session, the session object in cache is also extended. This does seem to work the "correct" way.

View 1 Replies

Data Cache Support Background Population Of Cache Entries?

Aug 1, 2010

We have a data driven ASP.NET website which has been written using the standard pattern for data caching (adapted here from MSDN):

public DataTable GetData()
{
string key = "DataTable";
object item = Cache[key] as DataTable;

[code]...

The trouble with this is that the call to GetDataFromSQL() is expensive and the use of the site is fairly high. So every five minutes, when the cache drops, the site becomes very 'sticky' while a lot of requests are waiting for the new data to be retrieved.

What we really want to happen is for the old data to remain current while new data is periodically reloaded in the background. (The fact that someone might therefore see data that is six minutes old isn't a big issue - the data isn't that time sensitive). This is something that I can write myself, but it would be useful to know if any alternative caching engines (I know names like Velocity, memcache) support this kind of scenario. Or am I missing some obvious trick with the standard ASP.NET data cache?

View 3 Replies

C# - Maximum Length Of Cache Keys In HttpRuntime.Cache Object?

Feb 24, 2010

We are using HttpRuntime.Cache API in an ASP.NET to cache data retrieved from a database.

For this particular application, our database queries feature a LOT of parameters, so our cache keys look something like this:

table=table1;param1=somevalue1;param2=somevalue2;param3=somevalue3;param4=somevalue4;param5=somevalue5;param6=somevalue6... etc...

we have so many parameters that the cache key is several hundred characters long. is there a limit to the length of these cache keys? Internally, it is using a dictionary, so theoretically the lookup time should be constant. However, I wonder if we have potential to run into some performance/memory problem.

View 1 Replies

ADO.NET :: Use HttpContext.Current.Cache (system.web) For Cache Data Something In Project

Sep 13, 2010

I have use Nhibernate in my MVC Project by me known, Nhibernate have cache on Session and Object. now, I want use HttpContext.Current.Cache (system.web) for cache data something in project. my code same that have problem, haven't it. and that's right or wrong.

View 2 Replies

Architecture :: Distributed Caching / Keeping Cache In Sync Between Multiple Webservers Or Even Better Farm Cache Management To Another Server?

Feb 26, 2010

I've got a web application that runs of a state server. It looks like soon it may need to distributed and there will be two web servers behind a load balancer.

This works great for session state but my next challenge is Cache

My application leverages heavily of cache. I understand ASP.Net 4.0 will be offering more here but nothing much has been said about the how too.

There are two challenges that I face

1). Each webserver will have its own copy of cache whereas it would be more efficient to put this to a third server the same as session state is put to state server.

2). The real challenge is keeping cache in sync if a simple dataset derived from the database is changed my code dumps that cache item and reloads the cache. That's all well on one webserver but webserver number two wont know to drop that particular cache item and reload it. This could cause some unexpected problems in the application.

For scenario number 2 I could attempt to do some smart coding so server number two knows to dump the cache and reload it.

My guess is someone else has already been here before and there's probably a better implementation approach rather than writing extra code.

Does anyone know how I could achieve the goal of keeping Cache in sync between multiple webservers or even better farm Cache management to another server?

View 2 Replies

Is Page Output Cache Stored In.NET Cache Object?

Nov 2, 2010

I need to enable caching in my asp.net application, but I do not want to use the webserver's memory for holding cache objects. If I add the page directive for output caching will the page be stored in the asp.net cache object?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved