Modifying Root Web.config In Code?
Jan 30, 2011
I would like to store some meta-information about a given site instance that can (a) be managed by that site instance and (b) persist clobbering of Web.config file.The site will run in multiple environments (dev,testing,staging and production) and each environment can have different values for this metadata.
Note: All environments are running IIS 7.0+
The Root Web.config seems very appealing, as it is certainly outside of the website. Therefore, both files and databases can be changed while maintaining the metadata. I have seen how to modify the appSettings of the Web.config stored in the website, but is it possible to similarly modify the appSettings in the Root Web.config (Specifically within the proper directive)?
View 2 Replies
Similar Messages:
Apr 28, 2010
I need convert my htaccess code to web.config code.
this is the htaccess code:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php HTTP/
RewriteRule ^index.php$ http://www.wonderstarter.com/ [R=301,L]
View 2 Replies
Jan 19, 2011
I just installed VS2010 and opened the root machine.config and web.config files for review and I found some errors. In machine.config, the following line has errors in both entries for <Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior>. When I hover the cursor over them I get a tooltip text which displays: "The element 'endpointBehaviors' has invalid child element 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior'. List of possible elements expected: '...(list of options here)...'. The same problem happens for the second appereance in tag <serviceBehaviors>.
[Code]....
In web.config, there is a tag called <protocols> that has an error with a tooltip text that says "The element 'system.web' has invalid child element 'protocols'. List of possible elements expected: '...(list of options here)...'.
View 2 Replies
Mar 11, 2010
I had a situation on a dev server where all the ASP.Net applications we have started to fail at the same time.After some investigation we found that calls the app settings, in 1.1 apps, and the connection strings collection in 2.0 apps all failed. The config files had the values, but the code was returning null.After some head scratching and searching I thought that perhaps the root web.config was being used and the sites one ignored. To test out this theory I added the app settings required for one of the sites to the root web.config. This allowed the site to work.
View 1 Replies
Nov 17, 2010
I have an xml file with custom routes that I'm creating routes from on Application_Start in Global.asax. Some of those routes require authentication, some don't. Currently I have "location" entries for all those routes in web.config to control authorization.
I wonder whether there is a way to configure locations on application start at the same time I configure routes, so that I don't need to have entries in web.config.
View 1 Replies
Jul 19, 2010
I've written a command line tool that deploys HTTP Handlers to an applications Web.Config file using a combination of System.Configuration, System.Web.Configuration and Microsoft.Web.Administration since it needs to register the handlers for both Classic and Integrated Modes as I don't know what mode end users will be using for their IIS deployments.
My issue is that is that when the tool is run the <handlers> section under <system.webServer> gets filled with the following extra unecessary entries as well as the entries I wanted to add:
[code]...
why this might be happening and how I can stop it?
When I save my configuration opened with System.Web.WebConfigurationManager I use ConfigurationSaveMode.Minimal so any inherited configuration (which is what this appears to be) should not get written.
View 1 Replies
Mar 14, 2011
I have an application with an HttpHandler that processes any requests for a .js file. I only want this handler to process *.js files that are requested in the root of the application.
The handler mapping looks like this:
<add name="HandleJS" path="*.js" verb="*" type="MyApp.JsHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
Currently, this handler processes ALL requested *.js files. Here is an example of the behavior I want.
This request would be processed by the handler: http://localhost/myapps/approot/script.js
and this one would not be processed by the handler: http://localhost/myapps/approot/dontProcessMe/script.js
I'd really like to avoid including the full absolute path in the handler path so I tried some other things first.
It doesn't look like the path property of the add element allows the use of the ~/ application root mechanism, so setting path="~/*.js" doesn't work.
I've also tried replicating the StaticFile handler that's built into IIS and doing something like this:
<add name="MyStaticFiles" path="*/*.js" verb="*" modules="StaticFileModule" />
or
<add name="MyStaticFiles" path="dontProcessMe/*.js" verb="*" modules="StaticFileModule" />
Both of which just return a blank response with an HTTP status of 200.
View 2 Replies
Jan 19, 2011
how can i specify two different login pages in root web.config file since i need to have authentication for two folders.for securing My Account module i did like this in the root folder i need to have it for another folder called EBox also.
View 1 Replies
Feb 7, 2011
We have 7 different development environments and only 1 domain name. Whenever we want to hit the particular environment we change the host file entry and modify the IP address to that domain name.
We are creating a web application which checks the health of all these servers. But the problem is we have to modify the hostfile of the system from the code to point to different environment this requires administrative previlages and so this is not best approach. Is there any way to hit the particular environment without touching the host file by using some kind of proxy?
View 2 Replies
Mar 1, 2011
I have a drop down box that is in the edit template of a formview. I want to be able to add a parrameter to the querystring when the drop down selected index is changed.
I tried
Request.QueryString.Add("tabindex", (sender as WebControl).TabIndex.ToString());
But I got an exception saying the collection is readonly.
Here is my markup
<icms_ref:ReferenceDropDownList ReferenceDataManagerProviderName="ROCSQLReferenceDataProvider"
ID="ddlEnquirerHearType" TabIndex="2" runat="server" ReferenceSetName="EnquiryHearType"
AutoPostBack="true" OnSelectedIndexChanged="EnquirerHearType_SelectedIndexChanged"
DataTextField="ShortName" DataValueField="ReferenceId" />
and here is my code behind.
protected void EnquirerHearType_SelectedIndexChanged(object sender, EventArgs e)
{
var pnlEnquiryHearTypeOther = fvEnquiryInformation.FindControl("pnlEnquiryHearTypeOther") as Panel;
pnlEnquiryHearTypeOther.Visible = DdlEnquirerHearType.SelectedValue == ((int)EnquiryHearType.Other).ToString();
ResetTextBox("txtEnquiryHearTypeOther", fvEnquiryInformation);
Request.QueryString.Add("tabindex", (sender as WebControl).TabIndex.ToString());
}
View 1 Replies
Jan 27, 2010
I ran into the following issue when trying to run a test website on IIS 7.5 (Windows Server 2008 R2 DatacenterEdition). The web-app is configured to run with framework version 3.5 in a .Net 2.0 app pool. Also the framework 4.0 beta 2 is installed on the server. The application named 'TestPfade' is located under the website's root named 'Default'. It is not only a virtual directory but defined as an application. The folder structure looks like this: The markup of the sole document reads as follows:
[Code]....
When viewed in a browser the image gets shown because the given relative path is correctly resolved to 'images/Lighthouse.jpg' but the paths to the ajax-framework resources also include the application's root folder and therefor aren't found: 'src="/TestPfade/WebResource.axd?d=1bX...' Here is the complete html-source generated:
[Code]....
View 9 Replies
Nov 30, 2010
In the root directory my web.config is doing the job of loggin in people to a website.
I don't need this behaviour in a directortory of the root directory. How do I solve this problem?
This are the authentication thins in my web.config:
[code]....
View 1 Replies
Feb 11, 2011
I am using iis 5.1 in which we have only only one default website, I have two projects v2 and v3 my website points to v2 projects and have some folders images, styles etc now i have a virtual directory under this website that is hosting project v3 and having the same folder hierarchy as v2 in the home page of the both projects i have img src="imagesedlogo.gif" alt="logo"/> but this shows the same image that is in the v2 directory, How can i show different images for both projects. using "" get the root of the web site but how can i get the root of virtual directory under that website
View 2 Replies
Sep 17, 2010
How can you request the root default.aspx without specifying it in the url for your root application?e.g. ttp://localhost/MyApp/ instead of http://localhost/MyApp/Default.aspxshould be able to do bothI'm not sure if this is a setting in IIS 7.5 for the application or what.
View 3 Replies
Sep 13, 2010
I'm making the switch from vb.net to C#. And with that, I want to move away from using sql datasources in the aspx page, and put the code to execute my sql statements "where it should be". Only thing is, I don't know where exactly that is. Basically, there are a three or four stored procedures that a page of this small website may need execute per page.Instead of putting all this in the code behind of the first page, and then copy/paste similar in other pages, I'd like to put it all together in one spot and then have each page "call" as needed. Problem is, I just don't know where/how this should be to do this the proper way. I'm trying to learn a better way of coding this...
protected void getSectionContent()
{
SqlConnection conn = default(SqlConnection);
SqlCommand comm = default(SqlCommand);[code]....
View 3 Replies
Jul 1, 2010
When your web.config or app.config file has an appsettings entry, what is the best way to refer to its key in your code file? Developers I have worked with have differing opinions on this. Some say to hard code the string and others suggest that there should be a file containing string constants and in your code, you use the constant as the appsettings key. I would be interested in hearing other opinions on this. What do you do? Why is it the best?
View 4 Replies
Mar 8, 2011
<sessionState timeout="1440"></sessionState>
how can i read value of timeout from web.config to c# code
View 2 Replies
Oct 18, 2010
I have mulitple websites using the same code but different web.config files. Is there a way where I can achieve not having multiple copies of the same code? so its easy to mantain?
View 1 Replies
Apr 30, 2010
I want to use the setting stored in the web.config file in my vb code, but don't know how to reference them.
More specifically I want to access the Host name, username and password in the smtp settings to send an email. My web.config is
[code].....
View 11 Replies
Nov 19, 2010
How Can We Have two Connection Strings In Web.Config And Switch Betweeen Them In Code Behind? when i add two connention strings in web.config so an error appears that tells us u cann't add two connection strings in web.config. i want the upper job because i have 2 databases and i want transfer data from another to the other one.
View 4 Replies
Mar 23, 2010
Is there a way I can dynamically register an IHttpHandler in C# code, instead of having to manually add it to the system.web/httpHandlers section in the web.config.
This may sound crazy, but I have good reason for doing this. I'm building a WidgetLibrary that a website owner can use just by dropping a .dll file into their bin directory, and want to support this with minimal configuration to the web.config.
View 2 Replies
Mar 15, 2011
I know this might be a very basic question, but maybe thats why im having problems finding the answer. Right now I'm creating database connections in my source files by doing something like this:
SqlConnection con = new SqlConnection("Data Source=...Password=...);
SqlCommand cmd = new SqlCommand(String.Format("SELECT * FROM Table;"), con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
But this means that if I choose to change databases it will be a major pain in the ass. Do you guys know how to use the connection string from a web.config file instead?
View 5 Replies
Feb 6, 2010
I am using ajax controls in my website. In my previous website I used these controls and they worked well but when I started a new website and I used these validators, fiter textboxes they donot work. I am adding the same dll of ajaxcontroltool kit and the same code in web.config. Don't know what is the issue.Please can anyone let me know why this happens or am I doing any mistake.
View 5 Replies
Oct 16, 2010
I have some pages that need user to sign in. If not, I need to redirect user to signin page. I know this can be done by using some code like"<system.web><authorization><deny users="?"/></authorization></system.web>" in web.config.
But can I just write some code to do the same function?
like in page load method, I can check whether user is sign in, if user is not signed in yet, how can I redirect user to the login page by using code? and how can I stop sending the content of the page to user?
View 3 Replies
Mar 27, 2010
I'm doing a code of sending email to a reciepnt, i did the behind cod and the SMTP configuraiton but it when adding the statement to the web.config page it gives me an Error. "Error 2 Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element. C:Documents and SettingsUserMy DocumentsVisual Studio 2008WebSitesWebSite2web.config 21 "I'm adding the following code inside the <configuration block as mentoined in another topic in the forum>
<system.net>
<mailSettings>
<smtp from="username@DomainName">
[code]...
View 16 Replies