.SelectSingleNode in Powershell script using xPath not working on extracting values from web.config file

Your XML file has a namespace: <configuration xmlns=”http://schemas.microsoft.com/.NetConfiguration/v2.0″> so you need a namespace manager for SelectSingleNode (see section “Remarks”): XPath expressions can include namespaces. Namespace resolution is supported using the XmlNamespaceManager. If the XPath expression includes a prefix, the prefix and namespace URI pair must be added to the XmlNamespaceManager. Something like this should work: … Read more

Editing Web.config programmatically

This fellow shows sample code if you still want to do it after all the caveats: protected void EditConfigButton(object sender, EventArgs e) { Configuration objConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(“~”); AppSettingsSection objAppsettings = (AppSettingsSection)objConfig.GetSection(“appSettings”); //Edit if (objAppsettings != null) { objAppsettings.Settings[“test”].Value = “newvalueFromCode”; objConfig.Save(); } } One valid reason for editing a web.config is to encrypt it, which … Read more

Is project.json deprecated?

Update: As of Visual Studio 2017 and the latest dotnet CLI, project.json is officially dead. Visual Studio will migrate projects automatically, and there is a comparison chart here: https://learn.microsoft.com/en-us/dotnet/articles/core/tools/project-json-to-csproj project.json is indeed going away. As part of a future update to the .NET Core tooling, .xproj/project.json will be merged back into .csproj. However, the team … Read more