web-config
how to add files in web.config transformation process?
There are two ways for the web.config transform files to be generated within VS: If you have a web application project, Right-click on web.config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both … Read more
The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machine.
For version 12.0 you need to install MDAC 2010 from here. This has to be done on the server where you publish your application. You need to install the x86 version if the target machine is 32 bit or the x64 version if the target machine is 64 bit and your application is built with … Read more
URL Routing, Image Handler & “A potentially dangerous Request.Path value”
Asp.Net 4.0+ comes with a very strict built-in request validation, part of it is the potential dangerous characters in the url which may be used in XSS attacks. Here are default invalid characters in the url : < > * % & : \ ? You can change this behavior in your config file: <system.web> … Read more
.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
How can I reference an appSetting in a different part of web.config
Nope, the web configuration file cannot pull “settings” from itself; it’s not dynamic at all. The only sort of dynamic functionality is the ability to include other .config, but that’s just a “suck all these settings in as if they were part of me” kind of thing.
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
deploying AntiforgeryToken Error
One thing I noticed is that this error could be caused by having multiple @Html.AntiForgeryToken() pieces of code on the page. I had 2 on my page and once I removed the second one, this error went away.
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
maxReceivedMessageSize not fixing 413: Request Entity Too Large
The answer was staring me in the face. The config generated by svcutil was for the client. I was using it on the server. I was editing the bindings for the endpoints specified under <client>, which made absolutely no difference to the service. Adding a proper <service> endpoint and setting the maxReceivedMessageSize and maxBufferSize on … Read more