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?
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.
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?
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.
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?
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.
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. ...)
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.
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.
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.
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?
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?
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.
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?
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.
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.
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 ?
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?