Can A Web.config Read From An External Xml File
Mar 9, 2010
I have to duplicate some settings (like connection string) between a web.config file that a WCF host uses and a web.config file that a web client uses.
In the interest of not duplicating, can I have both the web.configs read from a separate xml file? The two web.configs can be entirely in different solutions/projects so I guess this is not possible, but wanted to get other's opinion.
PS: I do understand I can use a database to store all the config settings.
View 4 Replies
Similar Messages:
Sep 1, 2010
We are experiencing some strange behaviour on one of our ASP.NET web servers (Windows 2003 64-bit). After some activity, two third-party controls are unable to run correctly. One is log4net (it does not write error messages out) and the other is a menu control (it displays eval message instead of picking up its license). The one common thread is that both controls pick up their config from external config files (linked to from web.config).
Just wondering if anyone has any thoughts on this or experienced this in any way. Is it related to file/folder rights? The server has been running fine for a while and just started exhibiting this behaviour. Perhaps it occurs around the time the worker processes are recycled.
View 1 Replies
Jul 8, 2010
I have many Connection strings in my web.config file. I also have a "dataConfiguration" setting in the same file which specifies what database my app connects to.
How do I read the "defaultDatabase" setting / section from the, see below xml file.
<configuration>
<configSections> [code]....
View 2 Replies
Jan 5, 2011
I am developing web applicaiton. I want to read web.config in App.config file. I have appSettings and connectionStrings in web.config. How to read that?
View 10 Replies
Jun 18, 2010
How to protect our web.config file from external access.
I mean some sort of password protection.
View 3 Replies
May 11, 2010
how can i access 2 external config files from web.config file.
i have done it for one external file like this in webconfig:
<appSettings file="........">
Now how can i access the second external config file from same webconfig.
View 1 Replies
Sep 25, 2010
I want to maintain different user authorization lists for different environments. I know that connectionstrings can be broken out in an external file with configSource, but how would I do this for the following?
<authorization>
<allow users="someuser1"/>
<allow users="someuser2"/>
<allow users="someuser3"/>
<deny users="*"/>
</authorization>
View 1 Replies
Oct 5, 2010
How can I put MembershipProvider, ProfileProvider and RoleProvider in one single external config file?
View 1 Replies
Feb 8, 2011
When the user clicks on it, another .aspx page should pop up. I used the code below and it works fine. But when we deploy this .aspx page, the IP address of the target IIS server will be different. So I am thinking of saving the IP address of target IIS server in web.config file and load it into the Window.open method of Javascript code (below).Qusetion 1: Is that right way to do? If so, how I can read web.config file from Javascript?
Code:
<script type="text/javascript">
function open_win() {
window.open("http://10.999.1.86/WebUI/HistoricalRuns.aspx", "_blank", "toolbar=no, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=1000, height=500");
View 7 Replies
Feb 17, 2011
I'm trying to use OpenExeConfiguration to read a different config file, but I can't find any good examples.I have a windows Service and some of the config data already exists in another windows service config file on the same server, and it makes more sense to use what is already there, rather than have to maintain the same data in 2 places.
View 2 Replies
Feb 22, 2011
I wonder how often the Web.config file is read by the server?And if the fact of the Web.config file is too large, influences the application performance?
View 2 Replies
Sep 13, 2011
I have code that reads a value from a config file (not web.config) given a key. It looks like this:
Code:
Public Shared Function GetCustomConfig(ByVal ValuetoGet As String, ByVal ConfigFileValue As String) As String
Dim Returnvalue As String = String.Empty
LoadConfig(ConfigFileValue)
For Each KeyValue As String In AppSettings.Keys
If KeyValue = ValuetoGet Then
Returnvalue = AppSettings.Item(KeyValue).ToString
End If
Next
Return Returnvalue
End Function
So if my config file which is named my.config has this entry: <add key="TempArea" value="c:Temp"/>I would call GetCustomerConfig("TempArea", "my.config") and the function would return "c:Temp". Most of the time this is what happens. But sometimes I get an exception: Collection was modified after the enumerator was instantiated.
Is there a better way to get the value given the key? This is code written long ago by my predecessor, and I am not sure I want to use it anymore. If I do use it, I will have to do something so that it is more reliable.
View 7 Replies
Aug 18, 2010
I'm trying to use the following command:
Dim xmlFilePath As String = _
System.Configuration.ConfigurationManager.AppSettings("XmlFilePath")
to retrieve the following setting:
<applicationSettings>
<MySolution.WebProject.My.MySettings>
<setting name="XmlFilePath" serializeAs="String">
<value>C:ASP.NETFolderMessageLog</value>
</setting>
</MySolution.WebProject.My.MySettings>
</applicationSettings>
However, xmlFilePath shows up as Nothing after that line of code is run. What's the correct code to get a setting out of the web.config file in an ASP.NET application?
NOTE: Although you can add keys individually to the <appsettings> tag, I'm trying to figure out how to use it with the "Settings" tab in the project's properties.
View 2 Replies
Jan 3, 2010
Question: I have an annoying problem with nhibernate.The problem is I cannot get any example I find on the web to work... I've now tried for two days...
The first problem was it wouldn't read the config file, so I had to move it into app.config / web.config.
The second problem is that whatever I do, I always get an error:
No persister for: NHibernate.Examples.QuickStart.User
I've searched google and I did change the mapping to embeded ressource, and I did add the mapping to the config file, but nothing helps...
The example is from this page:
https://www.hibernate.org/362.html
I've uploaded my Visual Studio 2005 project to
http://daniel-steiger.ch/exchange/NhibernateCrap.rar
View 2 Replies
Dec 29, 2010
I have a text file named gisQuery129.json that is created using Json.NET - [URL] There is an example on how to create a JSON file and I have done that successfully, but I want to read the file on a page load event and add the values to .NET textbox controls for input values in a query. The created file looks like the following:
{
"myData": {
"randomNumber": "129",
"Application": "MyMapApp",
"FeatureId": "ALL",
"Feature": "ALL",
"spatialQuery": "FEATURE_ID= '11111' AND REQ_SEQ_NUM= 1 AND RAND_PARAM= 129 OR FEATURE_ID= '22222' AND REQ_SEQ_NUM= 2 AND RAND_PARAM= 129"
}
}
I want to read the data in the above sample JSON data and then populate my textboxes something like this:
txtRandParam.text = "129"
txtApplication.text = "MyMapApp" and three more text boxes after that.
View 4 Replies
Jan 2, 2011
i have a xml configuration file like below format.
<setting>
<web>
<mailid>xxxx</mailid>
</web>
<network>
<logid>sd</logid>
</network>
</setting>
i would like to programmatically read entry from xml config file which is same as asp.net webconfig file reading.
View 2 Replies
Sep 8, 2010
I am trying to read a normal string from the web.config file. When I try to read a string from the web.config file the application doesnt seem to read it. I set my sqlconnection string in the web.config file. It reads a sqlconnection string but not a normal string.Here is my code:
web.config file:
<applicationSettings>
<MyApplication.Settings>
<setting name="Colour" serializeAs="String">
<value> "Red"</value>
</setting>
</MyApplication.Settings>
</applicationSettings
This is how I try to call the setting:
string strColour = Properties.Settings.Default.Colour;
I am using .net framework 4.0
View 2 Replies
May 7, 2015
i need add one key value in web.config and that values read in asp.net page and to bind that value to gridview?
View 1 Replies
May 18, 2010
I want to read an XML file located here
The data looks like this
[code]....
And I just want to be able to access those values. My limited knowledge of XmlTextReaders has lead me no where.
View 4 Replies
Nov 2, 2010
I have a website written in C# that was running fine on one server. We moved it to another server and have a couple issues. I am mainly a VB.NET coder but can do a few things in C#. This is not a project - it is a website and can open it in VS2008 no problem. This is an admin site for the whole website where the user can add customer comments, etc. When logging in, it works fine. I can go to one of the admin pages after logging in and works. If I go to two other different pages, I get this error:
Object reference not set to an instance of an object.
[Code]....
It turns out this is in the main.master page and it is used by the other pages that load fine. The ApplicationTitle variable is set right in the web.config file and like I said, it shows on the other pages.
My question is why would this code work fine for some pages and not two others? All of these admin pages are under a folder called Admin and the web.config file is in the root folder of the website. Its almost like these two pages cannot see the web.config file in the root folder? Why would that be if thats the case?
View 3 Replies
Jul 26, 2010
I created a Global Resource file for Error messages and I am attaching the associated message to the validator control as following.
<asp:RequiredFieldValidator ID="RVTest"
CssClass="ErrorMessage" runat="server"
ErrorMessage="<%$ Resources:ErrorMessage, RequiredFieldTestKey %>"
ControlToValidate="ReqFldTestTextbox"> </asp:RequiredFieldValidator>
This is working fine.
Now I am planning to move all the Global Resources to a different library let say MyResourceLibrary and created a resource file with name ErrorMessage. I have added the reference of the library to my ASP.NET project and trying to acces the message from my library as follwong.
<asp:RequiredFieldValidator ID="RVTest"
CssClass="ErrorMessage" runat="server"
ErrorMessage="<%$ Resources: MyResourceLibrary.ErrorMessage, RequiredFieldTestKey %>"
ControlToValidate="ReqFldTestTextbox"> </asp:RequiredFieldValidator>
But this is not working.
View 1 Replies
Oct 5, 2010
I am using an external config file (with MS Enterprise library):
[Code]....
In Global.Config I have a database settings:
[Code]....
But when I am trying to set a roleManager in web.Config:
[Code]....
it writes that can not find MainSqlServer connection string. I am understand why, so the question is - how to make this connection string (from external config file) visible to web.config.
View 3 Replies
Sep 20, 2010
Is it possible to have location authorization nodes in a web.config be external?
Such that I could take all of the nodes simlar to
[code]....
And move them outside of the web.config or something simlar? I find these nodes at an extreme amount of noise to a web.config when they're relatively static. Normally my approach would be to config source something like this but since it falls under the root node I'm not sure of it's possible with these nodes.
View 1 Replies
May 6, 2010
Our conn strs reside in an external file <connectionStrings onfigSource="ConfigurationConnectionStrings.config" />Is there a way to encrypt this external file either using aspnet_regiis or System.Configuration?
View 4 Replies
Mar 1, 2011
By external config files, I mean .config files other than web.config. I've seen all the examples on how to edit web.config at runtime, but I want to edit a config file referenced by a configSource for appSettings. I want to modify only the external file and I will handle the app recycle.
I would like to use a built-in class to deal with the edits, but if the only option is a manual File open/parse, etc, then sobeit.
The general behind all this being a Settings page that is viewed at app startup, user sets their particulars and then saves the changes, then the real app starts up. quick and easy install app/configure page, so I'd like to leverage .config if at all possible.
FOLLOWUP - Quick Snippet to use XmlDocument to change an appSetting key value:
string path = Server.MapPath("~/my.config");
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode node = doc.SelectSingleNode("/appSettings/add[@key='myKey']");
node.Attributes[1].Value = "myVal";
XmlTextWriter writer = new XmlTextWriter(path, null);
writer.Formatting = Formatting.Indented;
doc.WriteTo(writer);
writer.Flush();
writer.Close();
View 2 Replies