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:
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.
I have a custom section in a web application that I am having trouble encrypting. I have written an external .NET program that will encrypt both .NET 1.1 & .NET 2.0 web/app configs.Up until this point in time, I have never had to encrypt any custom sections for either type of application. Anyway, the way I set it up for my web application is I wrote a class library that I import into the web application which allows me to set up and read from the custom section in the web.config. That all works fine... I added the custom section, and the web pages are able to read the values fine.
I have created a custom configuration section in a c# class library by inheriting from ConfigurationSection. I reference the class library in my web application (also c#, ASP.NET), fill in the appropriate attributes and everything works great. The problem starts when I start adding validators.
For example, this property:
[ConfigurationProperty("appCode", IsRequired = true)] public string ApplicationCode { get { return (string)base["appCode"]; } set { base["appCode"] = value; } }
As is it works fine, but as soon as I add this:
[StringValidator(MinLength=1)]
It bombs with the following error:
The value for the property 'appCode' is not valid. The error is: The string must be at least 1 characters long.
I get this error even though a valid appCode value is in my web.config file. If I remove the validator it works perfectly.
Detailed Error Information Module IIS Web Core Notification Unknown Handler Not yet determined Error Code 0x80070032
Config Error The configuration section 'connectionStrings' cannot be read because it is missing a section declaration Config File \?C:inetpubvhostscno-o.comhttpdocsweb.config
I am trying to create a forgot password section within my login section and it doesnt seem to work.
In my forgotpassword.aspx page my code looks like this:
[code]....
According to our records, you have requested that your password be reset. Your new password is: <%Password%>
If you have any questions or trouble logging on contact a site administrator.
No connection could be made because the target machine actively refused it ::1:25
Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it ::1:25
I have this error: The configuration section 'connectionStrings' cannot be read because it is missing a section declaration on my site when loading this page [URL]. The rest of the site works [URL] Setup:The server is a hosting company - Mocha Hosting. [URL] contains a phpbb forum. This has been installed via the hosting company's web tool (Plesk). There is a root web.config, but there isn't in the /forum/ folder. The forum folder has been set by the phpbb installation wizard to be a virtual directory and application - and it appears to not have asp.net configured on it. The forum worked BEFORE uploading the root web.config file, and again if i temporarily remove the root web.config.
I have a couple of configuration files flxConnection.config and flxSecurity.config files which are being referenced from the Machine.config file like below.
I would like to encrypt the files (a) flxSecurity.config and (b) flxConnection.config using the RSAProtectedConfigurationProvider using a custom RSA key, which can be deployed to other servers. How is that possible? If possible, looked at a variety of stuff in the internet and they all seem to be referring to either Web.config or Machine.config encryption which is pretty straight-forward. This is how the flxConnection.config looks like,
For some reason the Custom Errors for 404 pages are not working on my production server, but they work fine on development. Instead of going to the custom 404.aspx page, it goes to the ugly IIS 404 page.
Here is my Custom Errors protion of my web.config:
[Code]....
I changed the defaultRedirect to also go to my 404.aspx page just to make sure I was catching everything, but still it does't work. I know I could change the IIS 404 error to also point to my 404.aspx page, but that will not work for me because I need to capture the "aspxerrorpath" in the querystring for .net 404 errors. The IIS method will not give me that.
I am just hoping it is a server configuration I missed somewhere, but everything on production looks the same as on development.
I am referring to errors generated by my asp.net. For example I created a sample page and wrote 'throw new Exception("some error")' as a test. How can I retrieve an instance of the exception or exception details in my "/error/error.aspx" page? Currently in my error page if I query Server.GetLastError() the return value is null.
My system: I have installed Windows 7, VS2010 and .NET40 and ASPAJAXExtSetup.msi I'm getting the error below.
Error Summary. HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
I am getting this error on a website. does that mean the server is not competible with asp.net 3.5
Configuration Error Description:An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
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?
Excuse me this common error. I´ve found a lot of info in Google but I´ve not found my error. I´m trying to read some data from a custom section in web.config and I don´t know which is my error?
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?
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