这个问题之所以存在,是因为它确实存在 具有历史意义,但事实并非如此 被认为是一个很好的主题问题 因为是本网站,所以请不要使用 作为证据,你可以问类似的问题 这里的问题。 更多信息:https://stackoverflow.com/faq
总有一些功能在边缘场景中很有用,但正是因为这个原因,大多数人都不知道它们。我要求的是课本上通常没有教过的特性。
你知道的是什么?
这个问题之所以存在,是因为它确实存在 具有历史意义,但事实并非如此 被认为是一个很好的主题问题 因为是本网站,所以请不要使用 作为证据,你可以问类似的问题 这里的问题。 更多信息:https://stackoverflow.com/faq
总有一些功能在边缘场景中很有用,但正是因为这个原因,大多数人都不知道它们。我要求的是课本上通常没有教过的特性。
你知道的是什么?
当前回答
类似于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>
它大大增加了我的开发时间,你只需要为你的电脑投资内存:)
编程的快乐!
瓦格纳·丹达
其他回答
如果您放置一个名为app_offline.htm的文件 在一个web应用程序目录的根目录,ASP。NET 2.0+将关闭应用程序并停止对该应用程序的任何新传入请求的正常处理,只显示所有新请求的app_offline.htm文件的内容。
这是在将更改重新部署(或回滚)到生产服务器时显示“站点暂时不可用”通知的最快速和最简单的方法。
另外,正如marxidad所指出的,确保文件中至少有512字节的内容,这样IE6才能正确地呈现它。
If you use web services instead WCF services, you can still use standard .Net membership to enforce authentication and login session behaviour on a set web services similarly to a how you would secure web site with membership forms authentication & without the need for a special session and/or soap headers implementations by simply calling System.Web.Security.FormsAuthentication.SetAuthCookie(userName, false) [after calling Membership.ValidateUser(userName, password) of course] to create cookie in the response as if the user has logged in via a web form. Then you can retrieve this authentication cookie with Response.Cookies[].Value and return it as a string to the user which can be used to authenticate the user in subsequent calls by re-creating the cookie in the Application_BeginRequest by extracting the cookie method call param from the Request.InputStream and re-creating the auth cookie before the membership authenticates the request this way the membership provider gets tricked and will know the request is authenticated and enforce all its rules.
将此cookie返回给用户的示例web方法签名如下: 字符串登录(用户名、密码)
后续web方法调用示例如下: 字符串DoSomething(字符串authcookie,字符串methodParam1,int methodParam2等,等),你需要提取authcookie(这是从登录方法获得的值)参数从请求。InputStreamis
这也模拟了一个登录会话并调用FormsAuthentication。签出在web方法,如注销(authcookie)将 使用户需要再次登录。
使用configSource拆分配置文件。
你可以在web中使用configSource属性。将配置元素推送到其他.config文件,例如: 而不是:
<appSettings>
<add key="webServiceURL" value="https://some/ws.url" />
<!-- some more keys -->
</appSettings>
...您可以将整个appSettings部分存储在另一个配置文件中。这是新的网络。配置:
<appSettings configSource="myAppSettings.config" />
myAppSettings。配置文件:
<appSettings>
<add key="webServiceURL" value="https://some/ws.url" />
<!-- some more keys -->
</appSettings>
这对于您向客户部署应用程序并且不希望他们干扰web的场景非常有用。配置文件本身,只是希望他们能够改变只是几个设置。
裁判:http://weblogs.asp.net/fmarguerie/archive/2007/04/26/using-configsource-to-split-configuration-files.aspx
可以将ASPX页面打包到一个库(.dll)中,并将它们与ASP. dll一起提供。净引擎。
您需要实现自己的VirtualPathProvider,它将通过Relfection特定的DLL加载,或者您可以在路径名中包含DLL名称。由你决定。
当覆盖VirtualFile时,奇迹发生了。方法,在其中从程序集类返回ASPX文件作为资源:Assembly. getmanifestresourcestream。ASP。NET引擎将处理资源,因为它是通过VirtualPathProvider提供的。
这允许插件页面,或者像我所做的那样,使用它来包含带有控件的HttpHandler。
在网站发布并部署到生产服务器后,如果我们需要对服务器端按钮进行一些更改,则单击事件。我们可以在aspx页面本身中使用new关键字来覆盖现有的click事件。
例子
代码背后方法
Protected void button_click(sender object, e System.EventArgs)
{
Response.Write("Look Ma', I Am code behind code!")
}
覆盖方法:
<script runat="server">
Protected void new button_click(sender object, e System.EventArgs)
{
Response.Write("Look Ma', I am overrided method!")
}
</script
通过这种方式,我们可以轻松地修复生产服务器错误,而无需重新部署。