Modifying Web.Config Handlers Section Generates Extra Unneeded Entries?
Jul 19, 2010
I've written a command line tool that deploys HTTP Handlers to an applications Web.Config file using a combination of System.Configuration, System.Web.Configuration and Microsoft.Web.Administration since it needs to register the handlers for both Classic and Integrated Modes as I don't know what mode end users will be using for their IIS deployments.
My issue is that is that when the tool is run the <handlers> section under <system.webServer> gets filled with the following extra unecessary entries as well as the entries I wanted to add:
[code]...
why this might be happening and how I can stop it?
When I save my configuration opened with System.Web.WebConfigurationManager I use ConfigurationSaveMode.Minimal so any inherited configuration (which is what this appears to be) should not get written.
I have set up a small SQL Server database for users to login and also create accounts. There is a problem with the connection string though. Whenever I use the connection string below in the web.config file I get a server error page and cannot view the website. However when I take out this connection string I am able to view the website albeit the database doesn't work.
I would like to store some meta-information about a given site instance that can (a) be managed by that site instance and (b) persist clobbering of Web.config file.The site will run in multiple environments (dev,testing,staging and production) and each environment can have different values for this metadata. Note: All environments are running IIS 7.0+
The Root Web.config seems very appealing, as it is certainly outside of the website. Therefore, both files and databases can be changed while maintaining the metadata. I have seen how to modify the appSettings of the Web.config stored in the website, but is it possible to similarly modify the appSettings in the Root Web.config (Specifically within the proper directive)?
A while ago when i started using VS 2005, i found that some assembly entries were automatically added to from web.config
and i was getting annoying errors. later i found i have added unneccessary references in my application. And its a feature that assembly reference are automatically added to assembly tag in Web.config, So dev don't have to worry about it.
Recently i used Interop.OWC11.dll in my application. And ^&*# got the annoying
"CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"
error again.. Assembly entry was not added automatically. I checked same for existing references in my application, for them to automatic entries is not happening.... ? :(
I have to write is down in Web.config manually... I don't understand why?....
I have an xml file with custom routes that I'm creating routes from on Application_Start in Global.asax. Some of those routes require authentication, some don't. Currently I have "location" entries for all those routes in web.config to control authorization.
I wonder whether there is a way to configure locations on application start at the same time I configure routes, so that I don't need to have entries in web.config.
When my Web.config transforms it is adding a new line before the end value tag in my ApplicationSettings. This new line is showing up in the setting and causing an exception. Example:
I would like to add this section to my machine.config in exactly the same way many articles and microsoft are suggesting:
<configuration> <system.net> <connectionManagement> <add name = [URL]/> <add name = "*" maxconnection = "2" /> </connectionManagement> </system.net> </configuration>
[URL] As soon as I do it though, I get this exception when trying to hit a page hosted on the IIS on the same machine: Parser Error Message: Unrecognized configuration section system.net. Source Error:
Line 9: settings that differ from their defaults. Line 10: --><configuration> Line 11: <system.net> Line 12: <connectionManagement> Line 13: <add address="*" maxconnection="24" />
Source File: C:WINDOWSMicrosoft.NETFramework64v2.0.50727Configmachine.config Line: 11 Where is the problem and how can I modify the machine.config so that I can finally control the maxconnection value?
I am wondering how to encrypt the below information in the "web.config" file of the "Account" folder (where we have the secured pages):
[Code]....
My issue here is that even after I compiled my application (using "aspnet_compiler -v /reports c: eports"), the information inside the web.config file of the Account folder still not encrypted, and I want to publish my site to the customer server. So, since this server is a customer server, then they can access this "web.config" file and change our web-application security behaviour (correct me if I am wrong). Basically, I don't want the customer to even have access to our secured pages when they access our web-application using the web browser. How to solve this issue?
The code I've used to get the HTTP Modules is basically
HttpModulesSection modules = ((SystemWebSectionGroup)config.GetSectionGroup("system.web")).HttpModules; // Depending on what we need to do... //modules.Modules.Add(CreateSomeModule()); //modules.Modules.Remove("SomeOtherModule");
This worked fine up until IIS7. The migration command %SystemRoot%system32inetsrvappcmd migrate config "website/" moves the modules into system.webServer, so my code is now updating the wrong section. Is there a built in way to get the proper module section that should be modified? Or do I have to add a check for the Request.ServerVariables["SERVER_SOFTWARE"] and return system.web/system.webServer depending on the string I get back?
I am referencing some classes in my _layout.cshtml file and I have the namespaces in my Views/web.config <pages><namespaces> section and the layout page does not resolve. If I put @using statements in the layout page, it works fine. Shouldn't the layout page respect the web.config section?
I've created a custom config section for my application. For some reason Visual Studio 2010 isn't picking up and of my custom properties. I'm getting warnings similar to this for all the "add" keys: Could not find schema information for the element 'urlFilterSection'
CONFIG FILE: <configSections> <section name="urlFilterSection" type="BotFinderApp.Models.UrlFilterSection, BotFinder" /> </configSections> <urlFilterSection> <urlFilterCollection> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> <add url="urlhere.com.au" numberOfIpsToExtract="10" /> </urlFilterCollection> </urlFilterSection> UrlFilterSection: namespace BotFinderApp.Models { public class UrlFilterSection : ConfigurationSection { public UrlFilterSection() { } [ConfigurationProperty("urlFilterCollection", IsDefaultCollection = false)] [ConfigurationCollection(typeof(UrlFilterCollection), AddItemName = "add", ClearItemsName = "clear", RemoveItemName = "remove")] public UrlFilterCollection Urls { get { var urlsCollection = (UrlFilterCollection)base["urlFilterCollection"]; return urlsCollection; } } } } UrlFilterCollection namespace BotFinderApp.Models { public class UrlFilterCollection : ConfigurationElementCollection { public UrlFilterCollection() { } protected override ConfigurationElement CreateNewElement() { return new UrlFilter(); } protected override object GetElementKey(ConfigurationElement element) { return ((UrlFilter)element).Url; } } } UrlFilter namespace BotFinderApp.Models { public class UrlFilter : ConfigurationElement { public UrlFilter() { } [ConfigurationProperty("url", DefaultValue = "", IsRequired = true)] public string Url { get { return (string)this["url"]; } set { this["url"] = value; } } [ConfigurationProperty("numberOfIpsToExtract", DefaultValue = "0", IsRequired = true)] public int NumberOfIpsToExtract { get { return (int)this["numberOfIpsToExtract"]; } set { this["numberOfIpsToExtract"] = value; } } } }
I'm getting an ConfigurationErrorsException when trying to load a custom section from my web.config.
I'm trying to register a custom section in web.config to load it later using a "Section Class". Suppose my section is orderService, and I register it in web.config as shown: <configuration> <configSections> <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> </sectionGroup> <section name="orderService" type="orderService"/> </configSections> <orderService available="true" pollTimeout="00:01:00" location="abc"> </orderService> <appSettings></appSettings> <connectionStrings/>
Then I try to load it with:
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); OrderService custSection = OrderService)config.GetSection("orderService"); <== The exception is thrown here (OrderService is a class that inherits from the class ConfigurationSection, and that defines a property for each orderService property, in this case: available, pollTimeout and location)
The exception says: An error occurred creating the configuration section handler for orderService: Could not load type 'orderService'. (my web.config path line 23) Does anybody know what am I doing wrong here? (I got it from the book APress: Pro ASP.NET 3.5 in C#)
I've been working on implementing a custom section in the web.config file for a little something I'm working for the past few hours, but I can't seem to get it working. The following is what I'd like to use as my XML structure:
Dim roleRedirectSection As LoginRedirectByRoleSection = DirectCast(ConfigurationManager.GetSection("loginRedirectByRole"), LoginRedirectByRoleSection)
...I get the following error:
Message: "An error occurred creating the configuration section handler for loginRedirectByRole: Could not load type 'sitename.LoginRedirectByRoleSection'. (W:Webs2010DEVsitenameASP 4.0web.config line 10)"
I am trying to get sections from specific .config file such like "my.config". WebConfigurationManager.OpenWebConfiguration can get the web.config in specific path. Maybe WebConfigurationManager.OpenMappedWebConfiguration can reach my purpose
actually i need the maxRequestLength value of the httpRuntime section in web.config to check if a postedfile's size is greater. What's the best way to read it?
In my web.config file, I have an authorization section that is supposed to deny all users EXCEPT for those included in the group specified. However, my login form doesn't allow these users to proceed to the next page - the login form just reappears as if the user has been denied. Code:
[Code]....
I have a user named 'test' that is in the Student Council group. I've tried 'allow users' and 'allow roles' with no success. I've also confirmed that the user is able to log into any workstation in my domain.
If I add a namespace element to the system.web pages namespaces section of the web.config do I still have to add references in the code behinds in order to have access to the members of that namespace at design-time?
[code]... causes the following error Cannot create an instance of UI.Common.Unity.RequestLifetimeManager`1[T] because Type.ContainsGenericParameters is true.How do you reference generic lifetime managers?
I have a few pages that need to use SSL and I am confused bc I read you should set the forms authentication section in the web.config to use SSL. so if this is the case, the user logs in (login page is using ssl) the forms auth cookie is created and now if i redirect to the non ssl enable home page, does this mean the auth cookie will not be transmitted, so i can't display like a welcome module or know the username of the user who logged in?
i have the following property which takes an IP address as its value and defined in my custom config section as follows and To validate the IP address i am using a Reg expression.