C# - Can Apply Common Namespace From Web.config To App_code Class File

Nov 14, 2010

I am relatively new to asp.net environment.Recently working on a project, i discovered a problemi.e. I had to add using system.io to all file functions in any page. same for using sql functionsi.e. any method for that namespace had to be used in full like By adding the following section in web.config , ALL my pages automatically have access to that namespace

<namespaces>
<add namespace="System.Data"/>
<add namespace="System.Data.SqlClient"/>
<add namespace= "MySql.Data.MySqlClient"/>
<add namespace="System.IO"/>
</namespaces>
[code]...

View 2 Replies


Similar Messages:

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

How To Create A Common Web.config File And A Bunch Of Specific Web.config Files

Feb 16, 2011

Currently, I work on an ASP.NET project which is hosted under version control and is used on several developer machines, tester machine and production environment.

In three cases, configuration (Web.config) may be different. For example, developer and tester environments use testing SQL Server, whereas in production environment, another SQL Server is accessed, so the connection string is different in those cases.

We want to keep three versions of Web.config in subversion. But modifying each of three files every time we need to add, remove or change a common setting is annoying: it would be nice to have a common, master Web.config, which will be inherited by each of the three Web.config files.

How to set up an ASP.NET project which will use a master configuration file and different slave configuration files on different machines, thus sharing the same project/source code/configuration files in subversion?

View 2 Replies

Can't Use Class In .cs File Under App_code?

Apr 10, 2010

I've developed a class and it is put in a .cs file under the app_code folder. The class is a public one and there is no namespace specifically defined for this class in the file.of my webpages uses this class. It works ok on my local machine. However after I uploaded the page to the web server and then try to display the page through internet, the sever told me the class name can not be found.

View 3 Replies

Accessing Class File In App_Code Not Orking?

Jul 1, 2010

While working on my FTP server, I am trying to access a class within my App_Code, but it is not working.When writing, the class is accessible/usable in the code like shown in picture. I get no build errors.But when I run it in the browser, I get an error stating that it cannot find my class.I've looked around some other posts on the forum, like using namespace, but it didn't work.

View 8 Replies

Security :: How To Get Windows Username From A Class File In App_Code

Jul 1, 2010

this is relatively simple, but how would i go about retrieving the windows login name from the class file in the App_Code folder. I have set up my website to run windows authentication, and can use httpcontext to get windows login name from code beihind, but without passing this to the class everytime, is it possible to get the login name from within the class?

View 2 Replies

Application Does Not Recognize Class File In App_Code VS 2010

Jan 23, 2011

Since App_Code doenst exist as an ASP.NET Folder, I manually added App_Code as a regular folder, then within that I placed technologydescriptor.cs. Although it now has the appearance of an ASP.NET Folder.But for some reason my code doesnt recognize this class if its w/in the App_Code folder. This is picked up if it is not within that folder- why?Error: "The type or namespace name could not be found, are you missing a using directive or assembly reference"

[Code]....

View 4 Replies

Visual Studio :: New Class File In App_Code In Vs 2010 In New Web Project Not Compiling

May 23, 2010

Best way to describe my issue with vs 2010.create a new website. create the App_Code folder. create a new class in the folder. put the line "x" in the class declaration. hit compile. And the website will compile with no errors. It's not "seeing" this new class as being part of the project best I can tell.

View 1 Replies

Web Forms :: Open Web Page From Common Code In App_Code?

Jun 22, 2010

I have a function that sends out emails when certain processes are complete. The function works great; however, in our testing lab, I want to be able to see the message that are going out and not have it actually send the messages. Since MsgBox does not work in the web environment, is there a way to open a new page/window from the common code? The page will have the message passed to it for display and I do not want to do a redirect as there are times when more than one email is going out.

View 2 Replies

WCF / ASMX :: How To Set WebService NameSpace In Web.config File

Aug 27, 2010

I am trying to put the namespace value as a key in web.config file, so that when I deploy this on production, I just have to change the namespace key in the config file only, not on all of my webservice cs files. But When I try to browse this webservice after changing this code I get compilation error.

web.config:

[Code]....

MyWebService.cs (this code works)

[Code]....

Compiler Error Message: CS0182: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

View 1 Replies

How To Find The File Path From A Namespace.class Name

Aug 26, 2010

I'm programatically looking ito a .aspx file and getting the file class name declared in its CodeBehind. For example, when analyzing myFile.aspx I read in its Page Directive and found its CodeBehind equals "myApplicationmyPage.aspx.vb". Then I use the code
below:

[Code]....

Now I want to read the BaseFile (class = myApplication.Forms.BasePage). However, to read in this file, I need I need to get its full path instead of its namespace.class hiearchy. In this case, the BasePage is wrapped in a different namespace declaration thus I cannot just change the '.' to '' in order to get the path.How can I get the path of BasePage so I can read it?

View 2 Replies

Error Calling A Class File & Namespace?

Feb 1, 2010

i have the same prblmi have a class file in app_code/fol1/fol2/class1.vbbut when i call it as dim x as new class1 i am not getting itshld the class file be placed in app_code folder or outsideactually i had creatd the namespace but i am not able to import i

View 8 Replies

List All Classes In Application (Including Class In App_Code And Partial Class(aspx Pages And Asmx User Controls)?

Nov 15, 2010

Is there any way to list all the class in my ASP.Net application(Including class in App_Code and Partial Class(aspx pages and asmx user controls)

View 3 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

Use Common Web.config For Solution In Dot Net?

Mar 5, 2011

I am going to develop the web application in asp.net. where as in this application there is 4 user perspectives. all are independent all togather. but I want to develop under the single web solution. also want to create the number web applications for each user perspective, under this solution. so can i use common web.config file for this solution? what will impact ? if can not then how to manage the config files so that I need to change configuration at once (if need in future)

View 2 Replies

Specifying Relative File Location In Web.config For Use By Standard C# Class Library?

Jan 6, 2011

I'm struggling to find a way of specifying a file location in web.config appSettings that avoids using hard-coded paths but allows a non-'web aware' C# library to find a file. The C# library uses standard File.Open, File.Exists methods, etc. to operate on a data file, which is stored in my web application (ASP.NET MVC) tree, e.g. under:

contentdataMyDataFile.txt

Requirements:

I want to be able to specify my path like, e.g.:

<appSettings>
this--> <add key="MyFileLocation" value="~contentdataMyDataFile.txt" />
not --> <add key="MyFileLocation" value="c:inetpubwwwrootfoocontentdataMyDataFile.txt" />
</appSettings>

I don't want the C# library to be aware of the web application it's being used in, as it is used in other software, and the web application has no need to know about the configuration of the C# library.

View 3 Replies

Static Class In App_Code?

Jan 8, 2010

If a static class is put in App_Code, does that imply only one instance will be created, shared by different http requests?Or each request still brings one request?

View 3 Replies

Configuration :: Use Common Web.config Across Multiple Projects?

Apr 2, 2011

can i use common web.config across multiple projects

suppose say i have one web and one wcf service both are using same data base

then if change database the i need to make changes in both config files

or i have some common keys and values

is it there any we to common out the things in to one config file and that can be shared by multiple projects

View 1 Replies

Get The URL Of The Current Page From Within A C# App_Code Class?

Oct 19, 2010

I have a logging class that, well, logs things. I would like to add the ability to automatically have the current page be logged with the messages. Is there a way to get the information I'm looking for?

View 4 Replies

Can't See Class Defined In App_Code VS2010?

Jun 25, 2010

I am using VS2010 and am creating an ASP.Net application.I have declared a class called "Calculator" in a class file called "Calculator.cs" in the App_Code folder.I have a form called "CalcDemo.aspx" with a code behind file. I try and use the "Calculator" class but intellisense can't see it. I thought App_Code is the common code repository for any classes I define and should be visible to all ASPX code behind files
The namespaces are the same like Webapp1.xxxx

View 2 Replies

Compileable Class-files In Another Dir Then The App_Code?

Apr 23, 2010

Is there anyway to actually have a class-file placed in any custom directory and still be able to compile it with the application?

View 4 Replies

C# - How To Get Common Library To Read App.config Of Current Executable

Apr 28, 2010

I have a common library and two executables. Each executable refers to the common library for some functionality. I would like the common library to read from the app.config of the exe which is currently running. Is there specific API calls to do this?

View 1 Replies

Build A Common Utility Class For .net Together?

Sep 1, 2010

Which method would you like to place in tyour common class in asp.net application? A common function which you use in almost all your asp.net project question.

View 5 Replies

C# - Common Class - Use Two Classes With Same Code?

Mar 18, 2011

I have following two classes:

public class A : System.Web.UI.WebControls.Button
{

public virtual string X[code]....

As you must be seeing the class A and B have exactly the same code , my question is how can I make a common class for it and use these two classes.

View 2 Replies







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