web-config

error occurred while establishing a connection to SQL Server

戏子无情 提交于 2019-12-18 05:42:14
问题 If I have my connection string in the web.config like this (added line feeds for better readability): <add name="conn" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=MyDB; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=D:\Products.mdf" providerName="System.Data.SqlClient"/> The connection works and I can connect to the database in the database explorer. When I specify the connectionstring in code or use ConfigurationManager to get it it doesn't work:

web.config transform from web.template.xml not working

别来无恙 提交于 2019-12-18 05:01:48
问题 I'm trying to get web.config transformations working as described here. We've used this method on other projects and it works without issue, but not on this new project. Here's what I've tried testing without success Changing name of wpp.targets file in case I got the project name wrong. I know the current one I'm using works since it's the only one that causes web.config to be rebuilt from web.template.xml this transform works. Only the sub templates don't work. Tried with xdt:Locator="Match

Will a child application inherit from its parent web.config?

混江龙づ霸主 提交于 2019-12-18 04:48:07
问题 I setup a IIS application from within an existing application. Will the parents web.config be inherited or is that something I have to set explicitly? 回答1: Yes it will without setting anything explicitly, and I don't know any way to prevent it. However many configuration sections will allow you to clear data inherited from parent files. E.g. <appSettings> <clear/> <add key=...> </appSettings> <connectionStrings> <clear/> <add ... /> </connectionStrings> 回答2: You can also use the remove tag to

ASP.NET Web.config AppSettings Performance

孤街醉人 提交于 2019-12-18 04:44:11
问题 I have a number of appSettings in web.config that are used frequently (i.e. on each post back). Does the ConfigurationManager hold these values in process or are there any performance gains to be had by copying these values into application state on ApplicationStart() and subsequently retrieving them from there? 回答1: AFAIK the configuration is read and parsed at startup and the data is held in memory thereafter. I don't believe any performance gains from caching the state in application

NLog config file to get configuration setting values from a web.config

≯℡__Kan透↙ 提交于 2019-12-18 04:44:11
问题 Is there a method to get a value from the <ApplicationSettings> section of a web.config within NLog layout variables? I already store SMTP details within my web.config and don't want to duplicate the settings just to use within my NLog.config. Ideally I'd like to do something like: ${aspnet-config:SmtpHostServer} which then fetches the value from the web.config 回答1: I couldn't see any obvious way to do this other than creating my own LayoutRenderer (see below). If you're putting into your own

Azure web.config per environment

大憨熊 提交于 2019-12-18 04:28:11
问题 I have a Azure project (Azure 1.3) in VS2010. There are 2 webroles, one web page project and one WCF project. In debug mode I want the web project to use a web.config for DEV enviroment, and when publishing the web.config for PROD must be used. What is the best way to do this ? Currently I am facing issues when using a Web.Debug.config with transform XSLT. It doesn't seem to work in Azure.... 回答1: Solve your problem a different way. Think about the web.config always being static and never

Run an ASP.NET website in a subfolder

≯℡__Kan透↙ 提交于 2019-12-18 03:55:56
问题 Is there a way of running an ASP.NET website in a subfolder of the website? As an example, say I wanted to run the screwturn wiki (http://www.screwturn.eu/) in a folder called "wiki" on my website, can I alter the web.config of the screwturn website to tell it that it is running in the "wiki" folder? (like saying that "~/" = "/wiki/") The wiki would then find its assemblies that are in "~/bin" in "/wiki/bin" and the same for all other folders below the new root. 回答1: Piece of cake, you can

Moving Settings to another config file

流过昼夜 提交于 2019-12-18 02:49:38
问题 Is it possible to move applicationSettings to another config file as it is possible with connectionStrings or appSettings? When I create Settings for my web application using the designer I get applicationSettings section in my web.config such as: <applicationSettings> <TestWebApplication.Properties.Settings> <setting name="AnotherSetting" serializeAs="String"> <value>Another setting value</value> </setting> </TestWebApplication.Properties.Settings> </applicationSettings> I would like to be

How to catch ConfigurationErrorsException for violating maxRequestLength?

試著忘記壹切 提交于 2019-12-18 02:47:37
问题 I am limiting file size users can upload to the site from Web.config. As explained here, it should throw a ConfigurationErrorsException if size is not accepted. I tried to catch it from the action method or controller for upload requests but no luck. Connection is resetted and I can't get it to show an error page. I tried catching it in BeginRequest event but no matter what I do the exception is unhandled. Here's the code: protected void Application_BeginRequest(Object sender, EventArgs e) {

Configuring wcf rest services in web.config

时光怂恿深爱的人放手 提交于 2019-12-18 01:06:04
问题 Where in the web.config should the following blocks of code go for a WCF RESTful service? <endpoint address="" binding="webHttpBinding"contract="Wcf_Test.IMyService" behaviorConfiguration="httpEndpointBehavour"> <identity> <dns value="localhost"/> <Identity> </endpoint> and <behaviors> <serviceBehaviors> <behavior name="httpBehaviour"> <serviceMetadata httpGetEnabled="True"/> <serviceDebug includeExceptionDetailInFaults="False"/> </behavior> </serviceBehaviors> and <endpointBehaviors>