`
mybwu_com
  • 浏览: 179112 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

Asp.net Configuration Part(1)

 
阅读更多

Asp.netConfiguration

Global asax

Common Events :

Application Start

Initializesome resource of application

Application End

Clean upresource

Application Error

Go tounexpected error Page

Application Dispose

Clean up

Session Start

Userspecific data initialize

Session End

Userspecific data finalize

Machine Config

<MachineKeyvalidationKey = “specific Value” Decryption Key=”specific Value” />


· Validation key is using for encryptview state

· for web Garden and web farm ,need toset as specific value, for saving view state value during post back.

Web Config

Configuration can be inheritance

For Http://localhost/A/B/C/MyPage.aspx

IIS will apply :

MachineConfig -> web Config -> A folder Web Config -> B Folder Web Config->C folder Web Config

Location

When wantto set more than 1 group of settings for different path , can use location tag

<Locationpath=”” >put this path specific settings</location>


Section class

Create a Section Class

ClassOrderService : ConfigurationSection {

[ConfigurationProperty(“available”,IsRequired…)]

Publicstring Available{get;set;}

}


Configuration

<Configuration>

<ConfigSections>

<sectionname=”OrderService” />

</ConfigSections>

</Configuration>

<OrderServiceavailable = “true” …other attributes/>

…

<System.Web></System.Web>


Use

OrderServicesection = (OrderService)ConfigurationManager.GetSection(“OrderService”);

varavailable = section.Available;


For Nested Configuration

Configuration

<Configuration>

<ConfigSections>

<sectionname=”OrderService” />

</ConfigSections>

</Configuration>

 

 

…

<System.Web></System.Web>


Create Section Class

ClassOrderService :ConfigurationSection {

[ConfigurationProperty(“location”,IsRequired=true)]

PublicLocation location{get;set;} 

}

ClassLocation : ConfigurationElement{

…

} 


Use :

Lbl.Text =section.location.ComputerName ;


Configuration section canbe encrypted

WAT

Web SiteAdministration tool

VS->Website->Asp.net Config

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics