Resolved Trying to add two parameters to 'configuration' element in the Web.config

bassdb

New member
Joined
Feb 12, 2022
Messages
2
Programming Experience
Beginner
Hello all,

I am a new programmer in C#. It is nice to meet you.

My Senior Developer told me I could add '2' parameters to a 'configuration' element in the Web.config file.

The code is this

Web.config error.jpg


The error is this

Error in Application.jpg



How can I add both to the configuration element?

xmlns="http://www.nlog-project.org/schemas/NLog.xsd" AND xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance to the 'configuration element' like it is written above?

I tried this

I added a comma between the parameters.:
<configuration xmlns="http://www.nlog-project.org/schemas/NLog.xsd",  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

I tried the configuration element on two lines:
<configuration xmlns="http://www.nlog-project.org/schemas/NLog.xsd">

<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Neither of these worked.


Thank you for any suggestions.
 
First of all, those two things you added are called "attributes", not "parameters".

Next, you can't use an anonymous namespace on the <configuration> element because that would be saying that <configuration> is now part of the NLog namespace. As the error that you got indicated, ASP.NET doesn't like that because it expects <configuration> to belong to the .NetConfiguration namespace for the web.config to be used properly. To fix your issue, provide an alias name for the NLog namespace so that <configuration> remains within its original namespace.

As a quick aside, your question is not a C# question. It's an XML question that applies universally to any kind of XML usage.
 
@anwarabbas : Did you give that a try in your own web.config and try to access the IIS hosted site? What results did you get?
 
Removing @anwarabbas ' post since he changed the original namespace URLs to spammy links.
 
First of all, those two things you added are called "attributes", not "parameters".

Next, you can't use an anonymous namespace on the <configuration> element because that would be saying that <configuration> is now part of the NLog namespace. As the error that you got indicated, ASP.NET doesn't like that because it expects <configuration> to belong to the .NetConfiguration namespace for the web.config to be used properly. To fix your issue, provide an alias name for the NLog namespace so that <configuration> remains within its original namespace.

As a quick aside, your question is not a C# question. It's an XML question that applies universally to any kind of XML usage.
Hi Skydiver,

Thank you for your help.

I took your advice and modified the 'Web Config' file.

I took the 'Attributes' away from the <configuartion> element, and placed the 'Attributes' in the <nlog> element like so.

NLog Element with Attributes.jpg


I no longer get an error. Thanks again!

You may close this.

Take care
 
Back
Top Bottom