C# - Performance Penalty For Storing Values In The Web.config Compared To Const Fields?
Aug 25, 2010
currently in our application we have an ApplicationConfiguration class. It is basically just a static class with const values specifying certain application-global configuration options. Some of these values will rarely if ever change and are only put into the configuration for elegance/cleanness.
Some of these values though do need to be different between production and development. So I'm considering making this class just a wrapper over Web.config. These values are checked many times throughout our codebase. If I change these from a const to a read-only getter that reads from Web.config will this affect compiler optimizations or make our application in any way slower?
View 1 Replies
Similar Messages:
Feb 14, 2011
As an extensibility option for my web application I would like to allow the user to add sections to it by simply making new folders and uploading files to them. So, for instance, if they created (in the webroot): /UserContent/StaticPages/First/Second/index.txt. Then in the main menu there would be a new menu point "First" with the submenu point "Second", which would lead to markdown-parsed version of index.txt. This way the user can upload any static menu points he wants (such as "About us", "Contact us", "Our Mission" etc.) Another extensibility point is that I would like them to add headers/footers to specific webpages in a similar fashion. I'm using ASP.NET MVC3, so there are pretty URLs, and it would be easy for the user to just create: /UserContent/Additions/Store/Categories/35/header.txt
And when someone opened [URL] the markdown-parsed header.txt would be prepended. This is simple for the user, and simple for me (I don't need to make sophisticated admin panels and WYSIWYG editors). However I'm worried about the performance. This scheme means that on each GET request I would need to scan the /UserContent/StaticPages folder and check for the existences of the header/footer files (several, because parent levels can have their header.txt/footer.txt as well).
I could cache the result, but then I have to manage the cache and the user will need to know that changes can take up to X minutes to display. Would this be a premature optimization? There won't be much data in those folders, so Windows will probably be able to easily cache their contents itself.
View 1 Replies
Nov 15, 2010
I'm working on an application which will store around 50.000 images within it's first year and another 75.000 in it's second. Images can come from Galleries, news images, article images and profile images. So I want to give each image a GUID and store the GUID in the database.As for the directory structure i was thinking of something like this:
~/Upload/Images/F2/50/F2504E0-4F89-11D3-9A0C-0305E82C3301.jpg
So I'm using the first 4 characters of the GUID as my directory structure to spread images a bit more evenly between directories. Now I have some questions about this approach:Is it considered good practice to store all different kinds of images together rather then use ~/Images/Upload/Profiles, ~/Images/Upload/Articles etc.I'm also storing thumbnails and they have a different GUID obviously so the thumbs will not be in the same folder as the original and somehow that doesnt give me a good feeling but I guess it should not matter but.Same goes for Galleries, I'm used to store galleries in folders like ~/Images/Upload/Galleries/12 , and now all the images from a gallery will be scattered around in different subfolders, is this a big performance hit?Do you guys have any other ideas for directory structures?
As you can probably see I'm a bit afraid to use this approach but since there will be lots of images maybe even more then the numbers i gave i have to let the control go I think :)
View 3 Replies
Apr 6, 2010
Does it have any major effect on performance/ memory if my web.config is really huge (say, 1000+ entries in <appSettings>)? Is it a good idea to maintain a different custom xml config file for all business specific settings for my app?
View 3 Replies
Aug 3, 2010
I dont know whether this simple task or not, but I tried to search in google but couldn't find anything.
I've a asp.net form and user enters some data in the text boxes provided. Whenever user submits the form, browser will save that form data. I don't want this form data to be saved in browser. How can I restrict the browser saving this form data without touching the browser settings?
Application is developed using asp.net and normal text boxes are used here.
View 2 Replies
Jul 21, 2010
There are a bunch of hardcoded strings in a ASP.NET application.
eg. string constSetting = "XYZ";
There are a LOT of them. Is there a tool/plugin for Visual Studio 2008 to refactor it in such a way that the constant string goes into web.config and the above line gets replaced by the retrieved string from web.config app settings?
View 2 Replies
Feb 15, 2010
What it best location to store various configuration settings of a web site modules. Creating class (that inherit ConfigurationSection) that map the settings in web.config file?Or creating some DAL and BLL clases that work with database?
View 5 Replies
Aug 25, 2010
I would like to store a collection of strings in the web.config. This collection would vary in size over time. I would like to be able to pull all of the strings in the collection into an array or collection in code. (.Net 4, asp.net)
i.e.
<customCodes>
<VendorCode vendorName="Name1" code="1234567891234567891324567987ddd" isActive="true"/>
<VendorCode vendorName="Name2" code="1sadfsadf1234567891324567987ddd" isActive="true" />
<VendorCode vendorName="Name3" code="123456789dfadfdsaf3324567987d32" isActive="true"/>
</customCodes>
I could use appsettings with the strings all in one value but I would like to seperate it out for organizational reasons. Not using the key/value pair complicates things a bit. I am now getting a message that states "you can't have duplicate elements in a section"
View 2 Replies
Jun 24, 2010
We have a large multi tenanted website which requires thousands of lines of web.config to support it. As the system grows we are finding it more and more difficult to manage this configuration file.The system currently in place uses XSLT to generate the config but this solution seems to involve a lot of duplicated code (we have 12 deployment environments).
I am leaning towards putting the configuration data in the db so we can be sure that it's deployed with the application and that our release notes don't require the IT guys messing around with XML
What are better solutions we could use?
View 3 Replies
May 5, 2014
I am trying to make Login through webConfig but it is not working. When I click on Login with the user and pass it is not redirected to theAllowUsers page.
WebConfig
<authentication mode="Forms">
<forms loginUrl="~/RestrictedArea/Login.aspx" defaultUrl="~/AllowUsers.aspx" timeout="2880">
<credentials passwordFormat="Clear">
[code]...
View 1 Replies
May 31, 2012
I use this code to use in login
Code:
FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "SHA1")
My question is how about, i how can convert into a string where it display the user password so that i can send it to the user when he/she forgot it?
View 1 Replies
Aug 3, 2013
What I have write connection always in web.Config file and Why I can not write the connection in Application Variable ....
View 1 Replies
Feb 2, 2010
I am writing an app that has a bit of process flow to it. On the save of a record, I need to check some fields to make sure they are not null. If they are not null, I will update a 'SectionComplete' field to true.
The thing is, I would like to store my fields in the web.config. So, I would like to have a string in the appsettings section that has a list of field names that are required. Then in my method, I would call these fields out and check each one for the specific record id, and then update the database.
I would like to do this in the web.config so we could add/remove columns without having to redeploy.
For example: my required fields are name, id, and phone. For section one to be labeled complete, all of these fields would need to be not null.
web.config would have this entry:
<add key="Stage1Fields" value="name, id, phone"/>
View 4 Replies
Feb 20, 2010
I have implemented Membership and Role Provider in my web site. Membership and Role information is stored in database created from aspnet_regsql option.
I want to store the access rights given to the pages in ASP.NET Configuation option in Database inspite of web.config file and want to give page wise add, edit, view and delete rights that should also be stored in database.
Is there any inbuit class like Membership and Role to add page access rights?
View 3 Replies
Nov 22, 2010
I was told to use a Repeater control in what I am doing which is a "Data Entry" screen with ASP.NET controls -a standard "address" like form. In cases, the fields on the form will repeated twice, once for the original values, one for the changed values. I have not used this control before but it seems like I have to bind to a database. Instead, I have an Entity object that has been obtained via a Repository. Can I bind to an object like this?
[DataContract()]
public class RON
{
[code]...
View 4 Replies
Jun 23, 2010
How to make a reference to public const string from aspx page with c#
In VB its <% = MY_DATA%>
View 1 Replies
Jan 15, 2010
I am new to c#.net.i have a method where i pass parameters in a loop and for each parameter there are different rows returned .rows (which have data of different data types) from database.I want to store that data rows somewhere like arraylist. and use for furthue peocessing.Plz tell me how to do this. enter code here
/*ideally Get_ChildAndParentInfo(int pointid) function returns array list but how to deal with array list containing datarows with different data types */
public static ArrayList Get_ChildAndParentInfo(int PointID)
{
[code]...
View 2 Replies
Jan 19, 2011
i have a list for my shopping cart which i currently store in my datatable and then store it in a session. to avoid using sessions is it best to create a class where the datatable is stored and can be accessed from anywhere?
View 2 Replies
Jun 9, 2010
how can we store the value which i entered in a textbox to table dynamically.
View 3 Replies
Apr 14, 2010
I am having a page where I need to maintain around 70 to 80 hidden fields to store some values. These are required because I need these values for executing some code at the client side (validations, calculations, etc,.) in java script.
Wanted to know if there is a better way of storing these values in my page instead of using hidden controls because I guess using so many hidden controls is making my page very heavy.
Something like a hash table or list dictionay that I can access from both the server side code and clint side java script?
View 2 Replies
Nov 29, 2011
I've created a website that allows users to register, log in, create tasks, be added to tasks. I want to the user to be able to add hours to these tasks, for a summary page that will contain a chart. I want to store all previous hours worked on the task so that the user will be able to view a chart on progress of the tasks? What would be the best way to go about implementing this? I'm using VB.
View 12 Replies
Apr 15, 2010
I have an ASP.NET project which has already some custom fields in it's web.config file. I've added in it three more fields and used them in my changes, and it's working great.
But where it needs to be used, there aren't these thre fields in the web.config (this was expected, I've just added by hand for tests and developing).
How do I check the existance of fields in web.config, and in case of not finding it, how do I add it permanently to the web.config ?
View 2 Replies
Oct 20, 2010
I have 2 ListBoxes..ie ListBox1 and ListBox2.When Move items from ListBox1 to ListBox2,I want to save listBox2 values in Xml Files.When i open the page it will load lListBox2 values.
View 1 Replies
Sep 22, 2010
I'm trying to store multiple selected checkboxes from a single checkboxlist, but i don't know where to start. Imagine i have three tables: tbl_events, tbl_organisors and tbl_settings and i want to store the organisors of an event. Each event can have multiple organisors, so each organisor should be added as a single row into tbl_settings. I know how to bind tbl_organisors to a checkboxlist, but how do i store the results (meaning: add the rows to tbl_settings) ?
tbl_events: Event_ID (PK) and Event_Name
tbl_organisors: User_ID and user_name.
tbl_settings: Settings_ID (PK), Event_ID and User_ID
Checkboxlist:
[Code]....
SQLDatasource:
[Code]....
Initially all checkboxes will be unchecked, but users must be able to select multiple organisors from the checkboxlist and then store them into the DB by submitting a form. So the query will look something like: INSERT INTO tbl_settings (user_id, event_id) VALUES (@user_id, @event_id). And this is where my head cracks
1) How do i loop through all selected checkboxes and store each value (user_id) in a new row in tbl_settings?
2) After saving, the users reloads the page and the organisors he just selected must be selected by default in the checkboxlist. How?
View 2 Replies
Aug 10, 2010
I've got a table where i'm storing a CheckBox.Checked value.
I'm using C# and the value of the field in the table im writing to is a bit.
myDS.InsertParameters["p1"].DefaultValue = CheckBox1.Checked.ToString();
The value placed in my table ends up being either "True" or "False".
So when I try to query the table based on that value with a stored procedure it doesn't work since its looking for a 1 or a 0.
I think the .ToString() is part of the problem but i don't know the syntax to have the value from the CheckBox.Checked to be written as 1s or 0s instead of true or false.
View 1 Replies