这个问题之所以存在,是因为它确实存在 具有历史意义,但事实并非如此 被认为是一个很好的主题问题 因为是本网站,所以请不要使用 作为证据,你可以问类似的问题 这里的问题。 更多信息:https://stackoverflow.com/faq


总有一些功能在边缘场景中很有用,但正是因为这个原因,大多数人都不知道它们。我要求的是课本上通常没有教过的特性。

你知道的是什么?


当前回答

这是最好的一个。把它加到你的网里。配置更快的编译。这是3.5SP1后通过这个QFE。

<compilation optimizeCompilations="true">

Quick summary: we are introducing a new optimizeCompilations switch in ASP.NET that can greatly improve the compilation speed in some scenarios. There are some catches, so read on for more details. This switch is currently available as a QFE for 3.5SP1, and will be part of VS 2010. The ASP.NET compilation system takes a very conservative approach which causes it to wipe out any previous work that it has done any time a ‘top level’ file changes. ‘Top level’ files include anything in bin and App_Code, as well as global.asax. While this works fine for small apps, it becomes nearly unusable for very large apps. E.g. a customer was running into a case where it was taking 10 minutes to refresh a page after making any change to a ‘bin’ assembly. To ease the pain, we added an ‘optimized’ compilation mode which takes a much less conservative approach to recompilation.

通过在这里:

其他回答

有两件事在我脑海中浮现:

1)你可以在代码中打开和关闭Trace:

#ifdef DEBUG 
   if (Context.Request.QueryString["DoTrace"] == "true")
                {
                    Trace.IsEnabled = true;
                    Trace.Write("Application:TraceStarted");
                }
#endif

2)您可以使用一个共享的“代码隐藏”文件构建多个.aspx页面。

构建一个类.cs文件:

public class Class1:System.Web.UI.Page
    {
        public TextBox tbLogin;

        protected void Page_Load(object sender, EventArgs e)
        {

          if (tbLogin!=null)
            tbLogin.Text = "Hello World";
        }
    }

然后你可以有任意数量的。aspx页面(在你删除VS生成的。designer.cs和。cs代码之后):

  <%@ Page Language="C#"  AutoEventWireup="true"  Inherits="Namespace.Class1" %>
     <form id="form1" runat="server">
     <div>
     <asp:TextBox  ID="tbLogin" runat="server"></asp: TextBox  >
     </div>
     </form>

你可以在ASPX中拥有没有在Class1中出现的控件,反之亦然,但是你需要记住检查你的控件是否为空。

System.Web.VirtualPathUtility

类似于optimizeCompilations= " true "的解决方案,这里有另一个可以加快你在构建之间等待的时间(非常好,特别是如果你正在处理一个大型项目):创建一个基于ram的驱动器(即使用RamDisk),并更改默认的“临时ASP。NET文件”到这个基于内存的驱动器。

关于如何做到这一点的完整细节在我的博客上:http://www.wagnerdanda.me/2009/11/speeding-up-build-times-in-asp-net-with-ramdisk/

基本上你首先配置一个RamDisk(同样,在我的博客中有一个免费RamDisk的链接),然后你改变你的网络。按此配置:

 <system.web>
 ....
     <compilation debug="true" tempDirectory="R:\ASP_NET_TempFiles\">
     ....
     </compilation>
 ....
 </system.web>

它大大增加了我的开发时间,你只需要为你的电脑投资内存:)

编程的快乐!

瓦格纳·丹达

在内容页中为masterpage启用智能感知 我敢肯定这是一个鲜为人知的黑客

大多数情况下,当你想要使用母版页中的控件时,你必须使用findcontrol方法并从内容页中转换它们,MasterType指令将在visual studio中启用智能感知

只需在页面上再添加一条指令

<%@ MasterType VirtualPath="~/Masters/MyMainMasterPage.master" %>

如果您不想使用虚拟路径,则使用类名

<%@ MasterType TypeName="MyMainMasterPage" %>

点击这里获取全文

HttpContext.Current.IsDebuggingEnabled

这对于决定要输出哪些脚本(最小或完整版本)或其他您在开发中可能想要但不是实时的脚本非常有用。