web-config

How to access Web.config from a referenced assembly?

I need to access a web application's web.config from a referenced assembly. I need to get the file's path or the configuration object. I can't do this using System.Reflection.Assembly.GetEntryAssembly as I do for the application's configuration of a windows exe. Thanks ...

Web.config register user control in another proyect

Hi, I have a .Net project called: Whatever.Web.UI: I use this proyect to put all the custom and user controls that will be reused in all the website projects. These are organized in two folders: - CustomControls folder (with all the custom controls) - UserControls folder (with all the user controls) This are future examples o...

Get the user's identity with no authentication

I have an ASP.NET app that writes files to a NETAPP. It's finicky, and the only way we could get it to work was to set <identity impersonate="true"/> and remove the <authentication.../> tag in web.config. This allows the app to write to the NETAPP (with the appropriate monkeying of permissions behind the scenes), but now my app can't tel...

Automatic change of web.config under source control during CI build

I am working with couple of friends on an ASP.NET MVC website. The project is maintained in SVN and I have CC.Net set up to checkout latest version and do automated build and deploy to a pre-production server. The default build configuration is set to Debug, but the automated build is set to build Retail. Everything works just fine, exce...

ASP.Net Mapping Values Lookup.

Currently in my ASP.Net applications web.config I have an application setting that stores a comma delimited list of mapping values, like the one below. In the code behind I need to perform a lookup on this data based on input values 1, 2, 3 etc. I can either string split it and loop until I find a match, or use Regex to pull the value fr...

Different configuration files for development and production in ASP.NET application

On a project I'm working on we have a web application with three configuration files; Web.Config Web.Config.TestServer Web.Config.LiveServer When we release to the test server, Web.Config is renamed to Web.Config.Development and Web.Config.TestServer is renamed to Web.Config, making that configuration active for the application. It is ...

How can i retrieve a connectionString from a web.config file?

I am writing an client application in C# which will be supposed to change ConnectionString settings in a web.config file from another application I wrote. How can I achieve this goal? Is there a way to load the web.config file in my application and read/change its data object orientated? Or do I need to parse it as if beeing a complete ...

Can't get Log4Net to work in our WCF application

We are trying to use Log4Net to log from our IIS 6-deployed WCF Application. We are trying to log to a file, but can't seem to get the log files to be created, let alone see the logging output in them. The pertinent pieces of out web.config are: <sectionGroup name="common"> <section name="logging" type="Common.Logging.Configuratio...

Where do I catch and handle maxAllowedContentLength exceeded in IIS7?

Hi all, I have an aspx page where I’m allowing a user to upload a file and I want to cap the max file upload size to be 10MB. IIS7, .NET 3.5. I have the following configured in my web.config file: <location path="foo.aspx"> <system.web> <!-- maxRequestLength: kbytes, executionTimeout:seconds --> <httpRuntime maxRe...

Creating virtual application/directory in physical folder on IIS/ASP.NET

What I want to achieve is simple: I have a website, say "my-site" - http://localhost In this website I have a (physical) folder "foo" - http://localhost/foo Inside the "foo"-folder I want to have a virtual directory (application?) called "upload", so the URL becomes http://localhost/foo/upload Notice that "my-site" is an empty websit...

ASP.NET 2.0 & Web.config: Is this correct <appSettings/>?

I'm looking in Web.Config to add a simple (from a book) amendment - <configuration> <appSettings> <add key="SupportEmail" value="[email protected]" />. </appSettings> </configuration> However in the web.config I see there is only the following sign/bracket/block(?): <appSettings/> I can't find the opening . And isn't that an i...

Rewriting a Url which can contain 1 or 2 querystrings with URLRewriter.NET ?

Hi, In my project, my /PropertDetail.aspx can get 2 querystrings. 1st one for the PropertyId /PropertDetail.aspx?PropertyId=5 2nd one for the Language /PropertDetail.aspx?PropertyId=5&Language=2 EDIT: and this page can get one of them or can get both of them, so my rewriter rule needs to handle both of them So, i have set these ru...

How much is to much for an application regarding keys in a config file?

I was looking at one of our legacy applications (ASP.NET 1.1/2.0 Web App) and had a tool to do a count of all key/value pairs. It seems that across 11 config files for the legacy application (app, web, data, and a bunch of custom config files) I found 1172 keys. I assume that some keys are no longer used and I wanted to convince the mana...

asp.net Authorization: location and IPrincipal.IsInRole

Scenario I'm using a Custom IPrincipal and IIdentity to do asp.net authorization. I set the Principal and Identity during the PostAuthenticateRequest event using an IHttpModule. The web.config looks approximately like the following: <system.web> <authorization> <allow verbs="GET,POST" roles="domain\group"/> <deny verbs="*" ...

Defining tagPrefixes in Web.config help

I am having a little bit of trouble getting my aspx pages to recognize my tagPrefixes. I have the standard ASP ones defined... <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" as...

problem with Web.config wiring a database

<connectionStrings> <add name ="MyDB" connectionString ="Data Source=.\SQLEXPRESS" providerName="System.Data.SqlClient"/> </connectionStrings> I've wired the above however I keep getting the following: System.Configuration.ConfigurationErrorsException: The requested database MyDb is not defined in configuration. Is there s...

Registering User Controls in web.config Shows Error, But Controls Work Anyway.

This has been bugging me all morning and I can't even figure out where the error is. In the current web site I am developing (it's not a web application, in case it makes a difference, there are user controls declared as follows: <controls> <add tagPrefix="uc1" tagName="TransitLinkAdmin" src="~\controls\TransitLinkAdmin.ascx"/>...

Login Membership .NET

Hi I was wondering what is the best way to force the user to login when arriving at a website, in .net. I have set up the Membership features and I was wondering what is the best way to ensure that no matter what address the user arrives at, they must first get authenticated before proceding to the page they requested. Any resources wi...

What is the best way to implement a 'Forgot your Password?' page?

I am using the Membership features in ASP .NET 2.0. I was wondering how I would implement a Forgot your password page when my application is configured to allow only authenticated users. Right now the only page that can be accessed is the login page. I want un-athenticated users to be also allowed to access the forgot your password pa...

Variables within app.config/web.config

I was wondering if it is possible to do something like this in the app.config or web.config: <appSettings> <add key="MyBaseDir" value="C:\MyBase" /> <add key="Dir1" value="[MyBaseDir]\Dir1"/> <add key="Dir2" value="[MyBaseDir]\Dir2"/> </appSettings> I then want to access Dir2 in my code by simply saying: ConfigurationManager.AppS...