web-config interview questions
Top web-config frequently asked interview questions
What is the difference between the customErrors
and httpErrors
sections of the web.config file in ASP.NET MVC applications?
What are the guidelines for using each section?
Source: (StackOverflow)
I wanted to know what is the meaning of
<modules runAllManagedModulesForAllRequests="true" />
I am using IIS 7.5 and I have a simple web application. Do I need to write this in my web.config file.
I have also written few http handler for jquery ajax call.
I am using form authentication and asp.net 4.0.
How can I determine which module I have to run and which is not to be?
Thanks.
Source: (StackOverflow)
While changing the maximum allowed file size for upload I stumbled on those two settings.
In the sytem.web you have the http runtime node with maxRequestLength.
In the system.webServer you have the requestLimits with maxAllowedContentLength.
Now which gets the priority over the other? And do we need to set both or is the last one (the one for IIS7) enough?
Source: (StackOverflow)
How can I modify / manipulate the web.config
programmatically with C# ? Can I use a configuration object, and, if yes, how can I load the web.config
into a configuration object ? I would like to have a full example changing the connection string. After the modification the web.config
should be written back to the harddisk.
Source: (StackOverflow)
I just upgraded to Visual Studio 2010 and MVC 2.0 and I noticed the Web.config has two additional files attached to it? Are these files used to specify debug and release specific settings, so you don't clutter up the main Web.config?
Does it even make sense to place a connection string in the root Web.config file if I have a local and remote one in the debug and release Web.configs respectively?
Thanks!
Source: (StackOverflow)
I've got a C# program with values in a config file. What I want is to store ampersands for an url value like...
<appSettings>
<add key="myurl" value="http://www.myurl.com?&cid=&sid="/>
</appSettings>
But I get errors building my site. The ampersand is not allowed. I've tried various forms of escaping the ampersands to no avail. Anyone know of the correct form to do this? All suggestions are welcome.
Source: (StackOverflow)
I'm trying to pick up the windows username when debugging in Visual Studio 2013. I am simply using:
httpcontext.current.user.identity.name
If I run this on my Dev Server it works fine, if I run it in debug mode on any previous version of Visual Studio it also works fine.
My problems is - If i run this on visual studio 2013 I get an empty string.
My web config is as follows.
<system.web>
<authentication mode="Windows"/>
<identity impersonate="false"/>
<authorization>
<allow users="*"/>
</authorization>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
<customErrors mode="Off"/>
</system.web>
Source: (StackOverflow)
I am getting the following error:
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast
to [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A
originates from 'System.Web.WebPages.Razor, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context
'Default' at location
'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.
Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context
'Default' at location 'C:\Users\MyName\AppData\Local\Temp\Temporary
ASP.NET
Files\root\63e7ff36\a1cb775d\assembly\dl3\8f568c18\9b7ddacf_d04dcf01\System.Web.WebPages.Razor.dll'.
I have searched accross stackoverflow for similar issues and i used their solutions but it doesn't seem to fix the issue i am experiencing.
It suddenly occured, i just pressed clean solution and this error popped up. I also started using nuget package restore on the solution. I updated my packages as well (using Update-package) so one of those might have something to do with this issue.
Source: (StackOverflow)
I have code that i am looking through regarding session time outs of the website. In the web.config i came across this code.
<authentication mode="Forms">
<forms loginUrl="~/Auth/SignOn.aspx" timeout="40" slidingExpiration="true" />
</authentication>
<sessionState timeout="30" />
Does anyone know if one takes precedent over the other, and how they are different. Thanks.
Source: (StackOverflow)
I just installed vs 2010, followed by IIS in window 7. when building a website in .net framework 4.0 and convert this into application in IIS then its shows this error

If i remove the targetFramework="4.0"
from web config file then it shows me a second error which is related to linq
reference error

This all happening when i am using localhost to run my website but whenever i use just f5 in vs 2010 then its run perfectly.
When i want to attach my process with aspnet_wp.exe
i don't find this process in my list.
I searched a lot of answers here. What am I missing.
Source: (StackOverflow)
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.
The top line in all of my aspx pages in my /portal/ directory has this error message, and I know it's a common one. I have googled this error message to no end, and I see a lot of posts telling me to configure the /portal/ folder as an application in IIS (which I have), and more posts telling me I have nested web.configs (but none of the postings offer guidance toward a solution).
My setup is that I have a web.config in my root directory, and then I'm trying to make a company portal, in the /portal/directory. The /portal/ directory has its own (necessary) web.config.
My web.config line 50 is like this:
<customErrors mode="Off" defaultRedirect="customerrorpage.aspx"/>
<anonymousIdentification enabled="true"/>
<authentication mode="Forms"/>
<membership defaultProvider="MyProvider">
So I have domain.com/web.config AND domain.com/portal/web.config ... so my domain.com/portal/default.aspx page will not load.
What is the real solution to this? Do I somehow find a way to merge my root web.config with my /portal/ directory web.config, or am I way off base here?
Any guidance would be greatly appreciated!
Source: (StackOverflow)
Within an web.config
-file in an ASP.NET-application some sections of config, like appSettings
and connectionStrings
, supports the attributes file
and configSource
.
What is the difference between using the file
-attribute and the configSource
-attribute? When should you use which attribute and can you use both?
<?xml version="1.0"?>
<configuration>
<appSettings file="AppSettings.config">
</appSettings>
<connectionStrings configSource="ConnectionStrings.config">
</connectionStrings>
<!-- ... -->
</configuration>
Source: (StackOverflow)
I am trying to add
<location inheritInChildApplications="false">
to my parent web application's web.config but it doesn't seem to be working.
My parent's web.config
has:
<configuration>
<configSections>
</configSections>
// 10 or so custom config sections like log4net, hibernate,
<connectionStrings>
</connectionStrings>
<appSettings>
</appSettings>
<system.diagnostics>
</system.diagnostics>
<system.web>
<webParts>
</webParts>
<membership>
</membership>
<compilation>
</compilation>
</system.web>
<location ..>
<system.web>
</system.web>
</location>
<system.webServer>
</system.webServer>
My child web application is setup as an application in IIS, and is inheriting from the parent's web.config
which is causing problems.
Where exactly should I place the
<location inheritInChildApplications="false">
so it ignores all the various web.config settings?
Source: (StackOverflow)
is it possible to transform following web config appSettings file:
<appSettings>
<add key="developmentModeUserId" value="00297022" />
<add key="developmentMode" value="true" />
/* oter settings here that should stay */
</appSettings>
into something like this:
<appSettings>
<add key="developmentMode" value="false" />
/* oter settings here that should stay */
</appSettings>
So, I need to remove one setting with developmentModeUserId key + I need to replace value for key developmentMode.
Thanks
Source: (StackOverflow)