Access key value from Web.config in Razor View-MVC3 ASP.NET

前端 未结 4 1061
谎友^
谎友^ 2020-12-22 17:57

How do I access a key value from web.config in my Razor view.

This is in my web.config in the Web Project root level.

 

        
4条回答
  •  情深已故
    2020-12-22 18:15

    Here's a real world example with the use of non-minified versus minified assets in your layout.

    Web.Config

    
    
       
    
     
    

    Razor Template - use that var above like this:

    @if (System.Configuration.ConfigurationManager.AppSettings["Environment"] == "Dev")
    {    
            
    
    }else{        
    
           
    
    }
    

提交回复
热议问题