关于AjaxPro的性能改进
作者:Truly
偶然发现AjaxPro的页面注册是相当花费时间的方法
初步对AjaxPro方法进行分析,它的页面注册方法
AjaxPro.Utility.RegisterTypeForAjax(typeof(命名空间.类名));
<script type="text/javascript" src="/ajaxpro/prototype.ashx"></script> <script type="text/javascript" src="/ajaxpro/core.ashx"></script> <script type="text/javascript" src="/ajaxpro/converter.ashx"></script> <script type="text/javascript" src="/ajaxpro/Space_For_Static,App_Web_gz3bdi8j.ashx"></script>
Literal l = new Literal(); l.Text = "<script type=\"text/javascript\" src=\"/ajaxpro/prototype.ashx\"></script>" + "<script type=\"text/javascript\" src=\"/ajaxpro/core.ashx\"></script>" + "<script type=\"text/javascript\" src=\"/ajaxpro/converter.ashx\"></script>" + "<script type=\"text/javascript\" src=\"/ajaxpro/ABC.Notes,ABC.ashx\"></script>"; Header.Controls.Add(l);
比如我在PageBase方法中定义了RegAjax方法:
public void RegAjax(Type type) { // 用来代替 AjaxPro.Utility.RegisterTypeForAjax(Type type);方法 string assemblyName = type.FullName + "," + type.Assembly.FullName.Substring(0, type.Assembly.FullName.IndexOf(",")); if (type.Assembly.FullName.StartsWith("App_Code.")) assemblyName = type.FullName + ",App_Code"; Literal l = new Literal(); l.Text = "\n<script type=\"text/javascript\" src=\"/ajaxpro/prototype.ashx\"></script>\n" + "<script type=\"text/javascript\" src=\"/ajaxpro/core.ashx\"></script>\n" + "<script type=\"text/javascript\" src=\"/ajaxpro/converter.ashx\"></script>\n" + "<script type=\"text/javascript\" src=\"/ajaxpro/" + assemblyName + ".ashx\"></script>\n"; Header.Controls.Add(l); }
RegAjax(typeof(Mythos.QianXun.BusinessRules.Notes));
AjaxPro.Utility.RegisterTypeForAjax(typeof(Mythos.QianXun.BusinessRules.Notes));