这个问题之所以存在,是因为它确实存在 具有历史意义,但事实并非如此 被认为是一个很好的主题问题 因为是本网站,所以请不要使用 作为证据,你可以问类似的问题 这里的问题。 更多信息:https://stackoverflow.com/faq
总有一些功能在边缘场景中很有用,但正是因为这个原因,大多数人都不知道它们。我要求的是课本上通常没有教过的特性。
你知道的是什么?
这个问题之所以存在,是因为它确实存在 具有历史意义,但事实并非如此 被认为是一个很好的主题问题 因为是本网站,所以请不要使用 作为证据,你可以问类似的问题 这里的问题。 更多信息:https://stackoverflow.com/faq
总有一些功能在边缘场景中很有用,但正是因为这个原因,大多数人都不知道它们。我要求的是课本上通常没有教过的特性。
你知道的是什么?
当前回答
HttpContext.Current.IsDebuggingEnabled
这对于决定要输出哪些脚本(最小或完整版本)或其他您在开发中可能想要但不是实时的脚本非常有用。
其他回答
System.Web.VirtualPathUtility
包含在ASP中。Net 3.5 sp1:
customErrors现在支持“redirectMode”属性,值为“ResponseRewrite”。显示错误页面而不改变URL。 表单标记现在识别操作属性。非常适合在使用URL重写时使用
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
面板中的DefaultButton属性。
它为特定面板设置默认按钮。