stay ASP and MVC In development , There are some parameters that need to be changed by the activity , The most common is the database link string <connectionStrings> Configured under node . In today's contact with the project , I came into contact with the custom configuration parameters , According to the needs of the project web.config Define the required parameter values in .

The specific methods :

stay <configuration></configuration> Add... Under node <appSettings></appSettings> node .

Then you can customize the configuration parameters under this node :<add key="KEY" value="VALUE" />

Usage method :

ConfigurationManager.AppSettings["Key"] obtain web.config Corresponding value in .

Be careful : Use ConfigurationManager You need to refer to the namespace System.Collections.Generic;

web.config Sample configuration file :

<add key="APPID" value="wx116a17a17689178c"/>
<add key="APPURL" value=""/>

Use the custom configuration example :

public static string Appid
return ConfigurationManager.AppSettings["APPID"];


public static string AppUrl
return ConfigurationManager.AppSettings["APPURL"];


About ASP.NET Of web.config More articles about the little notes of

  1. in web.config Configuration file details ( Two )

    Excerpt from I've been watching, notice Web.config There is something very unclear , From the Internet .MSDN collect ...

  2. in web.config Configuration file details ( One )

    This article excerpts from in web.config Configuration file details web.config It's a XML file , Used to store Asp.NET Web Configuration information for the application , Including database connection characters . Authentication and so on , Can appear in Asp. ...

  3. Maybe something you should know ASP.NET Core Web API Use tips

    One . Preface In the current trend of software development , Whether it's front-end separation or service-oriented transformation , The back end is more built by API Interface services to And other clients to provide business support , How to build a compliance . Easy to manage ...

  4. in web.config Configuration node complete explanation

    Recently I found some information about Web.config Configuration node article , I found that many of them were scattered , And there are few explanations about the function and usage of each configuration node . After a search, I found a good article , Here's a quote Original address  http://www.c ...

  5. in web.config Configuration node complete explanation 【 turn 】

    web.config File search rules : (1) If it exists in the directory of the current page web.config file , Check whether the node name you want to find exists , If so, return the result and stop searching . (2) If the directory of the current page does not exist web ...

  6. web.config Learning notes of

    Original address : Always right web.config Don't know much about it . These days, taking advantage of the project ...

  7. Asp.Net And Web.config Configuration file details

    stay In general, the default configuration file name is web.config. Every web.config Documents are based on XML Text file for , And it can be saved to Web Any directory in the application . In the release Web Application time web.config ...

  8. ASP.Net stay web.config How to set the size of the uploaded file in

    modify Webcong file :<system.web><httpRuntime maxRequestLength="40960"   // namely 40MB,1KB=1024u ...

  9. ASP.NET The configuration file Web.config Explain in detail

    One . know Web.config file Web.config The file is a XML text file , It's used to store ASP.NET Web Configuration information for the application ( Like the most common settings ASP.NET Web How the application authenticates ), ...

Random recommendation

  1. eclipse Medium removal build Always js Wrong question

    In use eclipse The following box often pops up when the name is unknown , Sometimes it's even a dead cycle . Seriously affect development efficiency . The reason analysis is some of our projects js Code ,eclipse There was an error in verification , In fact, there is no mistake . I do not know! eclipse How ...

  2. PHPSESSID Of cookie

    If PHP There's... In the script : 1 session_start(); It shows that SESSION. SESSION It's a mechanism , Data can be saved or transferred across files on the server , Often used in shopping carts, etc . SESSION Only in ...

  3. leetcode Interview preparation :Implement Trie (Prefix Tree)

    leetcode Interview preparation :Implement Trie (Prefix Tree) 1 subject Implement a trie withinsert, search, and startsWith m ...

  4. jquery mobile Picture adaptive screen

    jquery mobile If you don't give img If the label specifies the width , Can't achieve the effect of adaptive screen , Here is a remark :width:100%;

  5. codeforces C. DZY Loves Sequences The question : Here you are. n Sequence of Numbers , And then let you change one of the numbers , Get the length of the longest ascending continuous sequence . Ideas : Let's start from the left and work out the continuous increment ...

  6. KVM The second : configure network

    1. install KVM a. adopt yum Install the virtualization package [root@kvm ~ ::]#yum install -y kvm virt-* libvirt bridge-utils qemu-img explain : ...

  7. 3064: Tyvj 1518 CPU monitor

    Pay attention to the problem of maintaining the maximum addition of history and the maximum coverage of history /************************************************************** Problem: 3064 Us ...

  8. Deep learning framework PyTorch The study of a Book - The third chapter -Tensor and autograd-2-autograd

    Reference resources I hope you can go directly to the above website to check the code , Here are my notes torch.autograd Just for the sake of Fang ...

  9. PAT L2-014 Train dispatching The structure of the train dispatching track in the railway station is shown in the figure below . Both ends ...

  10. Python Interface automation --SSL 3

    Official document reference address : in the light of SSL Warnings,u ...