C# - Caching, What Would Be A Best Practice

Aug 13, 2010

I have a table that stores songs and plays counter.
Here's the code:

//Increse plays counter
string ip = Request.UserHostAddress;
if (!string.IsNullOrEmpty(ip))
{
if (Cache["plays:" + trackID + ":" + ip] == null)
{
tracks.IncreasePlaysCounter(trackID);
Cache["plays:" + trackID + ":" + ip] = true;
}
}

I wonder what would be a better practice, store many cache items(like this) or store one item like a ArrayList that would contain the users who already heard that song. Is there any difference?

View 2 Replies


Similar Messages:

State Management :: Partial Page Caching (user Control Caching) And Button Events?

Jun 14, 2010

I have a page with a number of user controls, In one of my user controls I have a button event. I turn on output cache for the user control that has the button and vary by control using the ID property of a hidden field control in the user control. whenever I turn on the output cache my button event doesn't fire.

View 2 Replies

WCF / ASMX :: Implement Caching Using System.Web.Caching?

May 15, 2010

how to implement caching in wcf service using System.Web.Caching

View 2 Replies

Using Include Files Still The Best Practice?

Jun 14, 2010

Is the classic way of using include files still the best practice in ASP.NET. IS there a better way in ASP.NET to simulate include files? IF not can someone please provide an example of the .NET way?

View 5 Replies

Where Can I Find The Tasks To Practice

Sep 16, 2010

I am a beginner of C# programming. I have read a few books about C#.net. But I cannot find some exercises in the books. Someone told me to build up a blog to practice my coding.

But it is a huge task for a beginner. I just want some tasks to have a step by step learning process.

View 3 Replies

Declaring Variables Without As, Bad Practice?

Oct 20, 2010

I just noticed that I can save a lot of spacing by not using "as" when declaring variables, in some cases (not sure if this is something new in VS2010). For example:

Dim Name as string = "Bob"

works the same as:

Dim Name = "Bob"

I prefer the latter as some of my type declarations can be very long due to the library I am working with, and omitting the types simplifies the lines and makes them more readable. I am wondering a few things:

1. Do the two methods function at all differently?

2. Is this a bad practice, or generally excepted?

3. Is there a name for this?

View 1 Replies

Best Practice When Using WebMethods And Session?

May 15, 2010

I want to reduce postback in one of my application page and use ajax instead. I used the WebMethod to do so.. I have a static WebMethod that needs to access the session variables and modify. and on the client side, i am calling this method using jQuery. I tried accessing the session as follows:

[WebMethod]
public static void TestWebMethod()
{

[code]...

The values are displayed correctly and seems to work.. but i would like to know if this practice is allowed as the method is a static methods and would like to know how it will behave if multiple people access the application.I would also like to know how developers do these kind of tasks in ASP if this is not the right method.

View 1 Replies

Security :: What The Best Practice For Next Scenario

Apr 27, 2010

1) All users can browse open web site content.

2) To access memebrs area users must login.

3) Users can create , edit/update, delete there profile/information only.

4) Users can see / view other users profiles.

5) Admin can browse, create, edit/update, delete an any profiles.

I found many different ways to implement it, but what the best practice. May be you can point me in right direction.

Application Web based, MsSQL 2005, .NET 3.5, Server 2003.

View 1 Replies

MVC 3 Add Column To Sql Table (best Practice)?

Feb 19, 2011

vs2010 (express)
.net 4.0
SQL 2008 (express)
MVC 3
C#
Entity Framework

I'm curious as to whether there is a well known way to add a column to a SQL table as a global change in MVC 3.

"Global change" referring to adding a column from database to UI... can someone please outline the fundamental steps.
(i.e., 1. add column in SQL table. 2. update .edmx (replace relative tables) 3. ...)

View 4 Replies

What Is The Best Practice Of Declaring The Variables

Oct 7, 2010

I just want to know the declaration of variables in a separate class file or declaring in the same aspx.cs file. the best practice of declaring the variables.

View 3 Replies

Using An Include File Bad Coding Practice?

Mar 18, 2010

Is using an include file bad coding practice in asp.net? I am aware of master pages, etc. but it seems like in this case an old fashioned include file works best.I have a home page and I have an "all other" page. The all other page is my master page. I place the header include on the master page and at the top of the home page.

<!--#include file="inc/inc_header.aspx"-->

View 11 Replies

Good Practice When Retrieving SQL Data?

Jan 19, 2011

I'm currently using the fantastic DorkNozzle 'framework' for building a very basic blog in .NET.My first "self-taught" script is as follows, and is for solely retrieving SQL results.

PHP Code:

<%@ Page Language="C#" MasterPageFile="~/Dorknozzle.master" AutoEventWireup="true" Title="Blog" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<script runat="server">[code]....

I should change to perhaps improve my coding style, without going down the MVC line just yet?

View 17 Replies

Best Practice For Using JavaScript On Partials And Views In MVC?

Feb 25, 2010

I started removing part of a view into a partial so that it could be reused on another view. However, I got stuck because there are some JavaScript functions on the original view that call some of the functions that belong to the partial. It seems wrong to call functions that are defined on the partial from the containing view (and vice-versa). What is the best practice for this situation?

View 3 Replies

Multi-select Control (best Practice)?

Jul 22, 2010

I wrote a schedule app -- in asp.net 3.5 -- used where I work to do all the scheduling, and it actually turned out quiet nice. The issue is, you can only schedule one employee at the time.Each job is one row in a database and equals one employee.We have a lot of jobs that involve multiple employees, so it would be much easier to create one entry that schedules 3 employees for the same job.I've looked at a lot of multi-select dropdowns and combo boxes. Here is what I would like some advice on.

If multi-select selects employee numbers 2202, 2403, and 3610...how is the best way to get that into the database?I'm thinking 2202, 2403, and 3610 get put into an array, and use a loop to add each entry into the database. The database stays the same, and when this gets posted, there are three new entries in the database, one for each of the employees.Am I thinking right or can maybe someone that has done this offer some insight to something that would work better?

View 5 Replies

What's The Best Practice For Displaying The Contents Of A DataSet In MVC V1.0

Jul 12, 2010

I am long familiar with using the ASP.net GridView in ASP.net forms to display the contents of DataSet on a web page. What is the best practice for displaying the contents of the DataSet in ASP.net MVC? I can add the DataSet to my DataVew dictionary in my controller, but I'm unsure of how to display it in the View page.

View 2 Replies

What I S Best Practice For Accessing Settings From Config

Feb 28, 2010

I want to know what best practice is for accessing settings in config file when you have dev/test/production types.

If you have different config for each type when you publish a ASP.NET website doesn't the config get copied as well??

View 3 Replies

Databases :: Roles In .net / Oracle - What Is Best Practice For This

Apr 20, 2010

I'm using oracle for my asp.net website. In website I have 3 different roles. Now do I need to create as many diff users in oracle as roles?

Someone in team insisted on having as many users in oracle. But then unnecessarily i have to maintain multiple connection strings in app.

like, I have manager/ team leader/ user roles.

Now the team member insists on having 3 users in oracle. then in DAL i've to check role and use corresponding connection string.

This is not very big app, but in all 12-15 aspx pages and some 10 table in oracle to be used only on intranet.

what is best practice for this?

View 2 Replies

C# - Best Practice To Create A Generic User Id?

Jun 21, 2010

What s the best way to implement a method that creates and assings ID s to user on a asp.net application?

I was thinking about using DateTime ticks and thread id

I wanna make sure that there is no collision and user ids are unique.

ID can be a string or long.

should i use MD5 on some information that i collect from user? what would that be?

I have seen that md5 collision rate is very low.

View 3 Replies

Architecture :: Best Practice For Handling Exception?

Jun 3, 2010

I devide my website on 3 layers :

DAL(Data Access) - simple extract data from DB using LINQ
BLL(Business Logic) -

cache data and in try/catch block call function from DAL and throw it to UI :
try
{
}
catch (Exception ex)
{
//Log error
throw ex
}

UI (User Interface) - simple working without handling any exception,

So if error occured in BLL i will be redirected to Error.aspx page with message that something wrong.

how and where handle exceptions, or may be exists common patter where handle and how to inform user about errors ? Can anybody share bes practice.

View 1 Replies

DataSource Controls :: Best Practice For SQL Connection?

Mar 11, 2010

I was just wondering what would be the best practice for sql connection in asp.net, when using a loop

[Code]....

or...

[Code]....

View 2 Replies

Best Practice In User Uploaded Documents?

Jan 8, 2011

I am embarking on a project that allows a few administators to upload various files and then make them viewable to a subset of the other users that can login to the site. I'm planning on using ASP.NET MVC and was wondering what the best way would be to store the files? Two thoughts came to mind, storing direcly on the server in a folder and storing them in a SQL database.

The first seems like it might be the most logical but how do you prevent an authenticated user from simply typing in the address of a file that they are not permitted to view. My first thought was to setup the folder so that it would be browsed directly via the web.config, but then how does the user view the files they are supposed to view?

Alternatively, I figured if I stored the files in a SQL server, this would prevent the problem just presented but then how does one take, say a PDF file, store it in the database and then render it to a webpage when requested. Secondly, is this efficient to store files in a SQL server?

View 2 Replies

Best Practice For Authorization In The Business Layer?

Sep 9, 2010

What is the best way (for a .Net 4 project) to implement authorization in the business layer. Simply I want to check whether a certain identity can access a certain action/resource.

I've tried to look this up in Patterns & Practices, but haven't found anything useful yet.

And what about PrincipalPermission of ASP.Net 2.0? Is this still relevant? What about maintenance?

I want to use an elegant solution, preferably (re)using asp.net role management.

View 2 Replies

WYSIWYG Best Practice For Handling Fonts Faces

Aug 23, 2010

I have a WYSIWYG textarea (CKeditor) in my CMS.Most of the users write the article first in a word document and then paste it in the textarea.

Sometimes they paste as plain text, but sometimes not. And sometimes the articles final result is a mess because of the HTML that Word generates.

I have problems specially with the fonts, people change font face in Word and when they paste text in the textarea, the font face used in Word remains (seems that Word uses the <font> tag.

View 3 Replies

Finding Best Practice To Check Local Mail?

May 21, 2010

i have built a small mechanism for users to send and receive mail inside my website. this mail system not involving smtp, it's only messages that are saved in the site DB.

right now the only way i can see for checking if a user has new mail is to check the db in every page the user is visiting during his stay in the site which seems to be a bit cumbrous, is there any better approach of doing such thing ?

View 13 Replies

Best Practice For Tracking State And Session Variables?

Apr 12, 2010

We're creating a new consumer/public-facing ASP.Net web app. There are two concerns:
--Use cookie or cookieless forms authentication?
--If we decide not to use cookies at all, how would you store the data that would otherwise be stored in the cookie (Customer ID, AffiliateID, etc.). Does the ASP.Net authentication framework track something like CustomerID?

View 2 Replies







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