再努力一点点

没有烟抽的日子
posts - 35, comments - 4, trackbacks - 0, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

置顶随笔

摘要: 负载均衡   通常面对高并发与大数据量都会使用负载均衡,使用多台服务器来共同承担压力。  接着许许多多的问题就来了。Http Request => (Server1, Server2, Server3)1. 服务器数据同步  1.1 数据库同步    通常只会用一个数据库服务器,所以数据库同步,不用额外处理。  1.2 文件同步      比如管理员登录后台,添加了一张图片,管理员的请求被均...阅读全文

posted @ 2010-09-12 12:03 ZhangPeng.Chen 阅读(258) 评论(1) 编辑

摘要: http://www.regular-expressions.info/阅读全文

posted @ 2010-06-24 14:34 ZhangPeng.Chen 阅读(16) 评论(0) 编辑

摘要: 一些多线程的文章阅读全文

posted @ 2010-06-19 20:38 ZhangPeng.Chen 阅读(45) 评论(0) 编辑

2011年2月23日

Error Time: ...
Machine Name: S20129
Request URL: http://www.site1.com/page1|||RequestType:GET|||UserHostAddress:...|||UrlReferrer:
Error Message:
Error Source: System.Web Error
StackTrace:
at System.Web.CachedPathData.GetConfigPathData(String configPath)
at System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp)
at System.Web.HttpContext.GetFilePathData() at System.Web.HttpContext.GetConfigurationPathData()
at System.Web.Configuration.RuntimeConfig.GetConfig(HttpContext context)
at System.Web.HttpContext.get_ImpersonationToken()
at System.Web.ClientImpersonationContext.Start(HttpContext context, Boolean throwOnError)
at System.Web.HttpApplication.ThreadContext.SetImpersonationContext()
at System.Web.HttpApplication.ThreadContext.Enter(Boolean setImpersonationContext)
at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext)
at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error) ========================================

还原错误http://www.site1.com/page1.
以dot结尾会出现以上错误

posted @ 2011-02-23 15:55 ZhangPeng.Chen 阅读(29) 评论(0) 编辑

Error Time: ...
Machine Name: ...
Request URL: http://www.site1.com/page1|||RequestType:GET|||UserHostAddress:...|||UrlReferrer:
Error Message:
Error Source: System.Web
Error StackTrace:
at System.Web.Util.FileUtil.CheckSuspiciousPhysicalPath(String physicalPath)
at System.Web.HttpContext.ValidatePath()
at System.Web.HttpApplication.ValidatePathExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) ========================================

今天查看Live上的Log文件,看看有哪些异常。
看到如下这个错误,异常发生在System.Web.Util.FileUtil.CheckSuspiciousPhysicalPath(String physicalPath)

System.Web.dll中有如下代码
internal static void CheckSuspiciousPhysicalPath(string physicalPath)
{
  if (((physicalPath != null) && (physicalPath.Length > 0))
    && (Path.GetFullPath(physicalPath) != physicalPath))
  {
    throw new HttpException(0x194, "");
  }
}

还原异常
http://www.site1.com/page1%20

posted @ 2011-02-23 15:16 ZhangPeng.Chen 阅读(43) 评论(0) 编辑

2011年1月5日

http://code.google.com/p/flot/
http://people.iola.dk/olau/flot/examples/

posted @ 2011-01-05 09:27 ZhangPeng.Chen 阅读(130) 评论(0) 编辑

2010年10月13日

windows下删除SVN版本控制目录下的.svn文件,把下面的代碼保存為clear.bat放在根目錄下雙擊運行即可

@echo On @Rem 删除SVN版本控制目录 @PROMPT [Com]

@for /r . %%a in (.) do @if exist "%%a\.svn" rd /s /q "%%a\.svn"
@Rem for /r . %%a in (.) do @if exist "%%a\.svn"
@echo "%%a\.svn"

@echo Mission Completed. @pause

posted @ 2010-10-13 21:09 ZhangPeng.Chen 阅读(73) 评论(0) 编辑

2010年9月12日

负载均衡

  通常面对高并发与大数据量都会使用负载均衡,使用多台服务器来共同承担压力。

  接着许许多多的问题就来了。

Http Request => (Server1, Server2, Server3)
1. 服务器数据同步
  1.1 数据库同步
    通常只会用一个数据库服务器,所以数据库同步,不用额外处理。
  1.2 文件同步  
    比如管理员登录后台,添加了一张图片,管理员的请求被均衡到Server1,那么这张图片会被保存在Server1,那么我们需要同步到Server2,Server3。
    可以使用软件监测某些目录来达到同步的目的,比如更新部署也是一样,每台服务器分别更新是相当麻烦,而且还要测试每台服务器是否一致,所以我们需要

    可以同步的工具。
  1.3 Session
    无法使用会话,因为会话会容易丢失,比如你的请求在Server1上,保存到Session中,你的下一个请求可能在Server2,就丢失了。
    不过Session有一些选项可以指定是否持久化,可以保存到数据库中等等。
  1.4 验证票
    配置machine key之类的,保证多台服务器生成的验证票之类的是一致的。
  1.5 静态变量要小心
    现在是每台服务器都有一份。

  1.6 缓存

    一定要保证多台服务器间缓存数据的一致性和同步性,使用Memcache

2. 压力测试

posted @ 2010-09-12 12:03 ZhangPeng.Chen 阅读(258) 评论(1) 编辑

2010年8月18日

Web.config中使用如下配置
  <system.net>
    <mailSettings>
        <smtp from="info@site.com">
            <network host="localhost" port="25" />
        </smtp>
    </mailSettings>
  </system.net>

使用localhost直接发送邮件。
在服务器上部署遇到异常:Mailbox unavailable. The server response was: 5.7.1 Unable to relay for info@site.com

需要配置IIS6 Manager的SMTP server
1. Open IIS6 Manager using Control Panel => Administrative Tools.
2. Open SMTP Virtual Server properties.
3. On General tab, Set IP address of the Web server instead of "All Unassigned".
4. In Access tab, click on Relay button, this will open Relay Restrictions dialog.
5. In relay computers list, add the ip addres 127.0.0.1.

posted @ 2010-08-18 16:31 ZhangPeng.Chen 阅读(635) 评论(0) 编辑

获取隐藏元素的高度有什么作用呢?
场景:
  一个dialog插件
    dialog.show(url)
      1. 显示loading
      2. 使用iframe加载url
      3. iframe加载完成,自动调整iframe的高度
      4. 显示dialog,隐藏loading
  
  第3步,自动调整iframe高度,我们可以使用$iframe.contents().find("body").height()获取iframe中内容的高度。
  不过由于dialog还没被显示出来,所以获取的高度始终是0,这样我们就没办法自动调整iframe的高度。

解决方案:
隐藏的时候使用visibility: hidden; display: block; 替换 display: none; 这样我们就可以获取到高度了。
显示的时候使用visibility: block;

posted @ 2010-08-18 16:26 ZhangPeng.Chen 阅读(48) 评论(0) 编辑

2010年7月30日

摘要: 刚才突然有点蒙,复习下。 :)代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><html><head><title></title><scripttype="text/javascript"sr...阅读全文

posted @ 2010-07-30 15:11 ZhangPeng.Chen 阅读(411) 评论(0) 编辑

2010年7月28日

摘要: 用Linq to sql挺长一段时间了,今天第一次碰到这个错误。场景重现及简化:[代码]这段代码普通的不能再普通,先取用户,设置角色,更新。不过出错了。在user.RoleId = roleId或者user.RoleId = null的位置会抛出异常System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException: Operation is ...阅读全文

posted @ 2010-07-28 17:44 ZhangPeng.Chen 阅读(184) 评论(1) 编辑

2010年7月27日

摘要: 1. document.location.reload() // 不好的地方: 如果是回发,会弹出一个是否重新提交的警告框。2. Response.AddHeader("Refresh", "0") // 0秒自动刷新,不好的地方:你还是可以感觉到是被刷新。3. Response.Redirect(Request.Url.AbsoluteUri); // 重定向到当前页面。 4. 如果回发了一次,...阅读全文

posted @ 2010-07-27 20:39 ZhangPeng.Chen 阅读(10) 评论(0) 编辑