C# - Is Having A Global Config Class A Bad Thing

Mar 6, 2011

Currently in my personal website I'm building I'm using a global static Config class to hold everything configurable I might need to change that is semi-global. So right now it looks about like this:

[code]....

Is using a global config class like this an anti-pattern of some sort? Also, I prefer for my connection strings to be outside of web.config. I like my web.config to be as minimal as possible.

View 5 Replies


Similar Messages:

Declaring A Constructor Private Or Declaring A Class Sealed Is Same Thing?

Oct 12, 2010

Is declaring a constructor private or declaring a class sealed is same thing?

View 1 Replies

Which Redirection Is Better - Web.config Or Global.asax

Feb 1, 2010

I need to redirect some of the older pages in my application to new pages. I thought urlMapping in web.config is the efficient way to achieve this. But there is also another way to redirect using global.asax. Which one is the efficient way for this. At what point in request execution does this asax and config file comes into the picture?

View 3 Replies

Web Config - How To Create A Global Stylesheet For Web App

Nov 12, 2010

I want to control the look and feel of my site by having two css files. One for colors and one for everything else. I want to put the colors css file in the App_Themes folder but I want to add the other file to every page on my site, but not add it to App_Themes because I want it to be loaded regardless of what Theme I am using.

Is there a way to add a reference in Web.Config for the global css file? I already have a reference to the styleSheetTheme for my css file with the colors in.

View 3 Replies

HttpModule In Global Web.config Working With VS Development Server But Not With IIS 7.0

Jun 29, 2010

I created a http Module following this tutorial. The module just displays a simple "Hello from OnBeginRequest in custom module.".I've referenced it in web.config and then, to satisfy my scenario (at work we need to see a module in action for all websites on a server, with the minimal configuration) I installed the module in the GAC, then I edited the "global" web.config in order tomake the module work for all the my web applications

View 1 Replies

Difference Between Using Global.asax And Web.config For Error Handling?

Apr 16, 2010

I'm working on a small web application, and I wanted the user to be redirected to a simple error page anytime an exception was encountered. So I wanted to redirect the user to generic Error page "Oooops.aspx" that will log the error in page_load.

I'm thinking that I can use Application_Error in Global.asax, where I can redirect to "Oooops.aspx" so that it displays a friendly error page and it logs the exception (through Server.GetLastError()). I can also use web.config and add "<customErrors mode="On" defaultRedirect="Oooops.aspx"/>" It'll redirect me to a friendly error page and it will also log the exception. What's the difference between these two? Should I use both of them, or just one? And which should I use?

View 4 Replies

Web Forms :: How To Set And Check Global User Class Or A Var

Apr 6, 2010

I have a .NET 3.5, C#, Silverlight 3, and LINQ Solution. My issue is this:

When a User goes to login I want to set a global class User; it has the properties of UserName and SecurityLevelId.

Then allow them access rights depending on SecurityLevelId. The real problem occurs because this project loads App page which calls the Shell page which calls the Navigation class. On Navigation instantiation it actually instantiates 6 other pages BEFORE you even get to the Login page.

So how in the World am I supposed to set and check all this if the page is loaded before I even go to it?

View 4 Replies

How To Read From LocalResources In Class Global Area

May 26, 2010

I have a class name xxxx and a resource whichthe class read from it to set some string. Everything is fine and nothing goes wrong.

The problem is that I have some Constant Global String which I set them in global area like

[code]...

The question is, How to read this strings from Resource File.

View 1 Replies

Visual Studio :: Intellisense Not Working For Assembly Registered In Global Web.config?

Nov 3, 2010

I made a custom server control library that all of our websites will be using. I have registered the dll in the global web.config of our production and development servers, and everything runs fine in the browser. The only problem I have is Visual Studio/Intellisense not recognizing my control. I get the error message "Unknown server tag...", which in turn throws other validation warnings. Does anyone know how to tell Visual Studio to include dll's registered in this location? Our sites are .net 4.0 and below is an excerpt from the web.config located in %SystemDrive%WindowsMicrosoft.NETFrameworkv4.0.30319Config on the servers.

<pages>
<controls>
<add assembly="[assembly info]" tagPrefix="irnrControls" namespace="IRNR.Controls"/>
</controls>
</pages>

It's not that big of a deal right now as I only have one control in the dll, but I would like to fix this before I add more controls.

Edit: I can't debug the site and it fails when I try to build it. The Output window displays "Unknown server tag".

View 2 Replies

How To Access Public Global.asx.cs Property From A Business Class

Feb 2, 2011

I have a property on my Global.asax.cs class that I need to access from a business class, i.e. using HttpContext.Current. How do I do this? Global.asax.cs (in a web project)

public partial class Global : System.Web.HttpApplication
{
public static ProxyGenerator Generator = new ProxyGenerator();
Business class (in a separate business project)
var generator = ((Sei.Osp.Web.Global)HttpContext.Current.ApplicationInstance)

This obviously doesn't work and I don't want to reference the whole web project in the business project as it will create a circular reference (the business project is already referenced in the web project)

UPDATE:

To clarify - the property I'm creating holds an instance of the Castle Dynamic Proxy Generator class. I've read that you shouldn't just create this all over the place. So I thought I'd create it in my Global.asax.cs and then just use that instance wherever I need to create a proxy class (I'm using it to do AOP) Is there a better way of doing this?

View 2 Replies

Web Forms :: Access Class / Import Namespace In Global.asax

May 31, 2010

I have added global.asax file in my webservice project. in webservice project i have one class file name as 'Class1.vb' in this class contain some methods() , i want to access those methods from 'class1.vb' in global.asax.vb file. any body knows how to access those methods in global.asax.vb. file

View 5 Replies

Way To Override And Inherit Default HttpApplication Class From Global.asax

Oct 19, 2010

am currently working on a web application, whereby I want to add code to the Application_BeginRequest method of the Global.asax file, without adding code to the Global.asax file, which sounds a little crazy, let me explain a bit more.If anyone has ever developed in sitecore before, they would have seen that the Global.asax file has empty methods, however it has 'using Sitecore;' and the global.asax file provided does not inherit from System.Web.HttpApplication.

View 1 Replies

C# - Declaring Global Variable/class In Application Scope 3 Ways - Which One Is Best

Mar 3, 2010

I am looking for differences between those 3 ways of using static class in asp.net application scope.
Will all of these point to the same class?

Which one is preferable >object< defined declaratively inside global.asax or static class ?

examples:

<object runat="server" scope="application" class="classname" ID="objID"></object>

VS

public static class classname {}

VS

Application("a") = new classname();

View 1 Replies

State Management :: Keeping Application Variable Or Static Class For Global String?

Nov 18, 2010

I need to keep a global variable throughout the whole time the user is at my site, but do I use Application or a static class? The string variable should store a region name and my site makes a few changes depending on which region that has been set.

I read that Application was mainly for classic ASP, but I also read that a static class cannot be instantiated at runtime (e.g. when the user has logged in).

So, have I got something wrong here and which solution do I use?

View 2 Replies

Class In App_Code Not Accessible By Global.asax.cs Error - Namespace Name 'MyClass' Could Not Be Found

Nov 18, 2010

I've created a new class in App_Code

namespace Site {
public class MyClass {
public MyClass() {
}
}
}

this is my Global.asax.cs

[code]....

The error is in: MyClass myClass = new MyClass();

The type or namespace name 'MyClass' could not be found (are you missing a using directive or an assembly reference?)

View 1 Replies

Way To Put Class Mapping In Web.config, Rather Than In Embedded Xml

Feb 4, 2011

Using raw nhibernate (no Fluent), is there a way to put class mapping in web.config, rather than in embedded xml? I can't seem to find any documents on this

View 2 Replies

DataSource Controls :: How To Use DSN Using Web.config And Class

May 15, 2010

i am using,Asp.net(vb),database sql server 2005, i want to use sysdsn DSN for database connection,so please Guide me how do i use DSN using web.config and class(we have sqlhelper type our own DBclass to set connectionstring for whole applicatoin. which get connection string from web.config),

Now,how do i use/set dsn in this type of scenario.

View 3 Replies

Are Session And Cookies The Same Thing

Sep 24, 2010

Since session and cookies are both used to store temporary data, what is the difference between them?

View 9 Replies

C# - Encrypting Class Library App.config File?

Jan 5, 2011

share your thoughts if there is any way to encrypt app.config section with out changing code? I know that we can use aspnet_regiis.exe to encrypt the web.config file.

I came across some blogs to rename app.config to web.config and run aspnet_regiis -pef command. I am able to create an encrypted version of app.config file but application failed to read the keys from encrypted app.config. so this approach didnt work for me.

View 1 Replies

Reading Config File From Class Library?

Jul 8, 2010

I a custom config file which I am having problems reading from a class project, is there a simple way to do this? the path does not seem to be getting picked up in code, where as this works in a web project

View 2 Replies

Is That Really The Possible Thing To Happen When Hiding A Datafield

Aug 23, 2010

My code below has a drawback. The scenario is this, i have two user roles - Approvers and Encoders. The encoders are not allowed to view the price only the approvers. Using the code below, i can now hide the Price column. but the problem is, when the encoder modified the quantity column, the Total Amount (Quantity * Price ) is zero. Giving zero value for price. When the approvers view the transaction,the Total Amount is zero. Is that really the possible thing to happen when hiding a datafield?

HTML Code:

For Each colField As DataControlField In colFields
If TypeOf colField Is BoundField Then
Dim bField As BoundField
bField = CType(colField, BoundField)
If bField.DataField = "ReceivPrice" Then
bField.Visible = False ' Hide Price Column
End If
End If
Next

View 13 Replies

How To Read Part Of The File - Not The Whole Thing

Feb 6, 2010

I'm using the filestream and streamreader to read a file, however I don't want to read the whole thing.
I only want to read part of the file, not the whole thing. I'd like to read up to string "abc123" and then "x" characters after it. I've managed to get the result I want by reading the entire file, then doing a few splits, but obviously, if the string I want to look for happens to be 5 characters in, it's a huge waste to continue reading the rest of the file.

View 5 Replies

Localization :: Culture And Locale Same Thing?

Apr 16, 2010

As per MSDN - Culture is name for traiditional wotd locale But at som many places, people use phrase like . "I am trying to implement culture and locale" Are they same or different?

View 2 Replies

Domain Validation Almost There But Some Thing Is Missing

Mar 24, 2011

I have a form where it checks the users mail ids for a particular domain like gmail.com so my code

[Code]....

Now I want to accept the Yahoo.com domain as well what I did was

[Code]....

View 9 Replies

WCF / ASMX :: Hard Code App.config Settings In Class?

Oct 19, 2010

I wonder how to hard code the configuration below in a class. I have a case where I cannot use app.config (due to creation of dll). The code below is probably not enough.. hard coded in class

ContractDescription contract = new ContractDescription("Common.MyInterfaces.IConnector");
Binding binding = new NetTcpBinding();
binding.Name = "net.tcp.binding";
EndpointAddress endPointAddress = new EndpointAddress("net.tcp://localhost:9001/Connector");
ServiceEndpoint serviceEndpoint = new ServiceEndpoint(contract, binding, endPointAddress);

[Code]....

View 3 Replies







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