C# - How To Create And Use A Custom Section In Web.config

Jul 10, 2010

how to create and use a custom section in web.config ?

View 3 Replies


Similar Messages:

Custom Server Controls :: Unable To Create A Forgot Password Section Within Login Section

Mar 10, 2011

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

View 2 Replies

C# - App.Config Custom Configuration Section

Dec 14, 2010

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; }
}
}
}

View 2 Replies

Configuration :: Registering A Custom Section In Web.config?

Feb 12, 2010

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#)

View 2 Replies

C# - Implementing A Custom Section In The Web.config File?

Jun 19, 2010

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:

[code]....

View 1 Replies

Is Default Value Necessary For The Validation To Fire Properly On Custom Config Section's Properties

Jul 26, 2010

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.

[ConfigurationProperty("SMTPServer", IsRequired = true, DefaultValue = "0.0.0.0")

View 1 Replies

IIS Configuration :: Adding Add Section In HttpHandler Section In Web Config Results In Blank Page?

Jul 12, 2013

with this code website works perfect

<configuration>
<system.web>
<httpHandlers>
</httpHandlers>
</system.web>
</configuration>

but when I add

<add path="ThumbHandler.ashx" verb="*" type="Delshad.WebControls.ThumbHandler,Delshad.ThumbPic"/>

or

<add verb="GET" path="CaptchaImage.axd"
type="MSCaptcha.CaptchaImageHandler, MSCaptcha" />

in httphandlers section when I go in my site it is only a blank page!

before In other two host there wasent problem but this is a new host and I face with this problem.also in local there isn't any problem.

View 1 Replies

Configuration :: Create A Custom Error Page In Web.config File?

Apr 14, 2010

If I create a custom error page in my web.config file, how do I retrieve error details in the error page?

So with ...

<customErrors mode="On" defaultRedirect="/error/error.aspx">
<error statusCode="404" redirect="/error/404.aspx" />
</customErrors>

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.

View 6 Replies

Why Can't Add Section To Machine.config

Mar 31, 2011

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?

View 3 Replies

Security :: Encrypting Section In Web.config?

May 3, 2010

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?

View 2 Replies

C# - Best Way To Get The Proper Modules Section From The Web.config?

Jan 19, 2011

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?

View 1 Replies

MVC :: How To Respect Namespaces Section In Web.config

Nov 18, 2010

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?

View 5 Replies

Error Trying To Read Roles Section From Web.Config

Feb 21, 2010

When executing this line:

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)"

<configuration>
<configSections>
<section name="loginRedirectByRole" type="journeyeast.LoginRedirectByRoleSection" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<loginRedirectByRole>
<roleRedirects>
<add role="Administrator" url="~/Account/Admin/Default.aspx" />
<add role="Employee" url="~/Account/Emp/Default.aspx" />
<add role="Teacher" url="~/Account/Teacher/Default.aspx" />
<add role="Student" url="~/Account/Student/Default.aspx" />
<add role="School" url="~/Account/School/Default.aspx" />
</roleRedirects>

View 1 Replies

MachineKey Config Section Default Location?

Sep 21, 2010

Where do I find the machineKey config section for ASP.NET?

I don't have one in my application Web.config, there isn't one in the root Web.config and there isn't one in my machine.config.

Does this mean there is some other default hardcoded into ASP.NET? If so, what are the defaults? (For .NET 2 and 4)

Having read this: [URL]

i was expecting to find something like this, somewhere:

<machineKey
validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps"
/>

Edit: the 1.1 docs seem fairly clear wrt default values: [URL] but the 4 docs are rather ambiguous [URL]

View 1 Replies

Use WebConfigurationManager To Get Section From Specific Config File?

May 14, 2010

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

View 2 Replies

Access HttpRuntime Section Of Web.config From Codebehind?

Feb 3, 2011

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?

View 1 Replies

Web Forms :: Programmatically Adding The WCF Section In Web.config File?

Jan 20, 2010

i want Programmatically add the WCF section <system.serviceModel> to web.config file using C# and .aspx control.

View 1 Replies

Security :: Authorization Section - Web.config Denying All Users

Jan 1, 2011

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.

View 20 Replies

Create Member Section For Website And Non Member Section

Aug 29, 2010

I'm trying to create a member section for my website and a non member section. I want the nonmember pages to have access to all the member pages but just not certain features like saving to the database. Is there a way to have the same page for both members and non members but have certain controls like buttons and other things that are only usable to the member that is logged in?

View 5 Replies

Add A Namespace Element To The System.web Pages Namespaces Section Of The Web.config?

Mar 26, 2011

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?

View 1 Replies

Asp.net - Working With Generic Lifetime Managers In Unity Config Section

Apr 28, 2010

I have the following generic lifetime manager

[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?

View 1 Replies

Security :: Login SSL Confusion / Forms Authentication Section In The Web.config To Use SSL?

Apr 15, 2010

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?

View 6 Replies

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.

View 1 Replies

How To Add New Custom Section Definition And Its Details

Dec 9, 2010

I want to add new configuration section definition in <configSections> in my web.config file using the IIS7 Management Console Configuration Editor and generate a script and execute this script in the installation to update the client's production servers.I was able to add the section definition using the following code:

ServerManager serverManager = new ServerManager();
Configuration config =
serverManager.GetWebConfiguration("Default Web site/upngisintegration");
SectionGroup rootSectionGroup = config.RootSectionGroup;
[code]...

View 1 Replies

Configuration :: Encrypting A Custom Section Programatically

Aug 11, 2010

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.

View 1 Replies







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