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

通过在这里:

其他回答

web.config中appsettings元素的'file'属性。

指定包含自定义应用程序配置设置的外部文件的相对路径。

如果你的应用程序设置很少,需要在不同的环境(prod)上进行修改,这是一个很好的选择。

因为网络的任何变化。配置文件会导致应用程序重新启动,使用单独的文件允许用户修改appSettings部分中的值,而不会导致应用程序重新启动。单独文件的内容与Web中的appSettings部分合并。配置文件。

你可以使用:

 Request.Params[Control.UniqueId] 

在viewstate初始化之前获取控件的值。文本等将在此时为空)。

这对于Init中的代码很有用。

在ASP。NET v3.5添加了一些路由,你可以创建自己的友好url,只需在页面管道的早期编写HTTPModule并重写请求(如BeginRequest事件)。

像http://servername/page/Param1/SomeParams1/Param2/SomeParams2这样的url将被映射到如下所示的另一个页面(通常使用正则表达式)。

HttpContext.RewritePath("PageHandler.aspx?Param1=SomeParms1&Param2=SomeParams2");

DotNetNuke有一个非常好的HttpModule来为他们的友好url做这个。对于不能部署. net v3.5的机器仍然有用。

CompilationMode="Never"是一个在某些ASP中至关重要的特性。网网站。

如果你有ASP。在asp.net应用程序中,ASPX页面经常通过CMS或其他发布系统生成和更新,使用CompilationMode="Never"是很重要的。

如果没有此设置,ASPX文件更改将触发重新编译,这将快速使您的appdomain重新启动。这可以清除会话状态和httpruntime缓存,更不用说重新编译引起的延迟。

(为了防止重新编译,你可以增加numRecompilesBeforeAppRestart设置,但这不是理想的,因为它会消耗更多的内存。)

这个特性需要注意的一点是,ASPX页面不能包含任何代码块。为了解决这个问题,可以在自定义控件和/或基类中放置代码。

在ASPX页面不经常更改的情况下,这个特性基本无关紧要。

这是最好的一个。把它加到你的网里。配置更快的编译。这是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.

通过在这里: