zoukankan      html  css  js  c++  java
  • 2008年4月小记

    1、布署ApplicationErrorLog未处理异常处理组件。
    A、引用相关组件。
    B、修改Web.config
    <?xml version="1.0"?>
    <configuration>
        
    <configSections>
            
    <section name="ApplicationErrorLogData" type="Lion.Web.ApplicationErrorLog.Configuration.SqlDataProviderConfigurationRuntimeData, Lion.Web.ApplicationErrorLog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
            
    <section name="ApplicationErrorLogMail" type="Lion.Web.ApplicationErrorLog.Configuration.MailDataProviderConfigurationRuntimeData, Lion.Web.ApplicationErrorLog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
        
    </configSections>
        
    <ApplicationErrorLogData Type="Lion.Web.ApplicationErrorLog.SqlErrorLog, Lion.Web.ApplicationErrorLog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" PageSize="17" RssPageSize="20" URLParamsUsePathInfo="false" NotLogHttpExceptionCode=""/>
        
    <ApplicationErrorLogMail Smtp="" SmtpPort="" LoginName="" LoginPassWord="" FromEmail="" FromName="" ToName="" ToEmail="" CC="test1@xxx.net;test2@xxx.net" AsynchronouslySendMail="false" MailCharset="utf-8"/>
        
    <system.web>
            
    <httpHandlers>
                
    <add verb="POST,GET,HEAD" path="ErrorLog.aspx" type="Lion.Web.ApplicationErrorLog.ErrorLogPageFactory,  Lion.Web.ApplicationErrorLog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
            
    </httpHandlers>
            
    <httpModules>
                
    <add name="ErrorLog" type="Lion.Web.ApplicationErrorLog.ErrorLogModule, Lion.Web.ApplicationErrorLog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
            
    </httpModules>
        
    </system.web>
        
    <system.codedom>
        
    <system.webServer>
            
    <modules>
                
    <add name="ErrorLog" type="Lion.Web.ApplicationErrorLog.ErrorLogModule, Lion.Web.ApplicationErrorLog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
            
    </modules>
            
    <handlers>
                
    <add name="ErrorLog"  verb="POST,GET,HEAD" path="ErrorLog.aspx" type="Lion.Web.ApplicationErrorLog.ErrorLogPageFactory,  Lion.Web.ApplicationErrorLog, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
            
    </handlers>
        
    </system.webServer>
    </configuration>


    注意:
         <add verb="POST,GET,HEAD"
           path="[查看异常列表所指定的路径文件名]"
           type="Lion.Web.ApplicationErrorLog.ErrorLogPageFactory, Lion.Web.ApplicationErrorLog, Version=1.0.2004.1027, Culture=neutral, PublicKeyToken=ee91461c95f67bb1" />
           查看异常列表所指定的路径文件名/clear 清空错误信息
           查看异常列表所指定的路径文件名/install 初始化安装数据库
           查看异常列表所指定的路径文件名/rss 获取以rss格式展现的错误信息列表
           查看异常列表所指定的路径文件名?Domain=www.lionsky.net 获取所有在www.lionsky.net域名下发生的错误信息列表
           />
         注意:当URLParamsUsePathInfo属性为false时,以上命令请使用?Command=[clear|install|rss]

    /ApplicationErrorLog.aspx?Command=install 安装日志数据库
    /ApplicationErrorLog.aspx?Command=clear 清空错误信息

    2、
    Master页面传值。
    A、定义接口IMasterData
        /// <summary>
        
    /// 母版页的数据
        
    /// </summary>

        public interface IMasterData
        
    {
            
    /// <summary>
            
    /// 登录用户名
            
    /// </summary>

            string UserName getset; }
        }
    B、Master页面实现该接口
    public partial class MPCommon : System.Web.UI.MasterPage, IMasterData
    {
        
    public string UserName
        
    {
            
    get
            
    {
                
    return this.ViewState["UserName"== null ? null : Convert.ToString(this.ViewState["UserName"]);
            }

            
    set
            
    {
                
    this.ViewState["UserName"= value;
            }

        }


        
    protected override void OnInit(EventArgs e)
        
    {
            
    base.OnInit(e);
            UserName 
    = ObjectFactory.CreateIPassportService().GetCurrentUser();
        }

    }
    C、封装方法
        public static class PageHelper
        
    {
            
    /// <summary>
            
    /// 获取当前登录用户的用户名
            
    /// </summary>
            
    /// <param name="page"></param>
            
    /// <returns></returns>

            public static string GetCurrentUserName(Page page)
            
    {
                IMasterData iMasterData 
    = null;

                iMasterData 
    = page.Master as IMasterData;
                
    if(iMasterData == null)
                    iMasterData 
    = page.Master.Master as IMasterData;

                
    if (iMasterData == null)
                
    {
                    
    throw new Exception("页面使用的嵌套Master没有实现IMasterData接口,不能通过这个方法获取当前登录用户名");
                }


                
    return iMasterData.UserName;
            }

        }
    这样可以支持两层Master的嵌套。
    D、使用方法。
        string CurrentUserName;
        
    protected void Page_Load(object sender, EventArgs e)
        
    {
            CurrentUserName 
    = PageHelper.GetCurrentUserName(this.Page);
        }

    3、解决"无法使用前导..在顶级目录上退出"
    修改web.config
            <authentication mode="Forms">
                
    <forms cookieless="UseCookies"></forms>
            
    </authentication>
    http://community.studyez.com/blogs/silentacorn/archive/2006/10/20/23194.aspx
    http://www.cnblogs.com/hjf1223/archive/2006/10/14/529227.html
    http://todotnet.com/archive/2006/07/01/7472.aspx

    4、TimeSpan的字符串表达,及如何设置WCF的毫秒级超时
    可以按“[-]d.hh:mm:ss.ff”格式将 TimeSpan 表示为一个字符串,其中“-”是用于表示负 TimeSpan 值的可选符号,“d”部分为天,“hh”为小时,“mm”为分钟,“ss”为秒,而“ff”为秒的小数部分。例如,初始化为 1.0e+13 刻度的 TimeSpan 表示“11.13:46:40”,即 11 天,13 小时,46 分钟和 40 秒。
    http://hi.baidu.com/heiru/blog/item/2e4cd42abfcea42dd52af12a.html
    所以500毫秒的超时可以这样设置 sendTimeout="00:00:00.5"
                    <binding name="IBlogContractBinding" sendTimeout="00:00:00.5" maxReceivedMessageSize="500000000">
                        
    <security mode="None"/>
                        
    <readerQuotas maxDepth="32"
                                      maxStringContentLength
    ="500000000"
                                      maxArrayLength
    ="16384"
                                      maxBytesPerRead
    ="4096"
                                      maxNameTableCharCount
    ="16384" />
                    
    </binding>



  • 相关阅读:
    Windows Live Writer Testing
    基于本地文件系统的LocalDB
    【笔记】动画显示窗体
    winform无边框窗口拖动
    关于js的内存机制
    flex-basis
    Cookie、session和localStorage、以及sessionStorage之间的区别
    关于报文
    关于http与https Tcp的三次握手四次握手
    关于前后端分离与不分离
  • 原文地址:https://www.cnblogs.com/chenjunbiao/p/1760216.html
Copyright © 2011-2022 走看看