我有一个网站项目我已经转换为.NET 4.5.我想用AuthConfig,我已经看到添加到App_Start目录.几个问题.
是App_Start目录仅适用于Web应用程序项目?当我尝试添加现有的asp.net文件夹,我不认为这是要添加的选项.
其次,如果是这样的话,我可以在我的网站项目中的任何地方使用AuthConfig文件吗?
好的,所以我在编写C#编程书时编写了这个程序(我试图在这里学习)并且它要求" 覆盖ToString()方法以返回所有数据成员 ".
我做得对吗?或者我只是成功地编写了编译但什么都不做的代码.ToString的目的是什么?
我花了大约30分钟来查看其他帖子,并没有想出来,所以我决定这样做.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication297
{
class Program
{
static void Main(string[] args)
{
String name = "Stormtrooper";
Employee s = new Employee(name);
Console.WriteLine("The type of hire is a {0}", s.Name);
Console.WriteLine("The identification number is {0}", s.Number);
Console.WriteLine("The date of hire is {0} ABY", s.Date);
Console.WriteLine("The standard galactic salary is...{0:C}", s.Salary);
}
class Employee
{
private string _name;
private string _number;
private int _date;
private int _salary;
public …Run Code Online (Sandbox Code Playgroud) 有没有办法可以用ASP.NET以编程方式在代码中设置Expires Header?具体来说,我需要将它设置在整个文件夹和所有子文件夹上,并且该文件夹仅包含静态文件(JavaScript,CSS,图像等)而不包含aspx文件,因此我不能只将一些代码添加到aspx代码中-behind page_load.
我通常可以直接在IIS中设置它.但服务器被客户端锁定(我只有FTP访问Web应用程序目录进行部署),并且让客户端在IIS上设置Expires Header将需要一个冰河时代(它是一个公共部门/政府网站).
我按照雅虎的建议http://developer.yahoo.com/performance/rules.html#expires进行前端优化的原因
更新:我试过创建一个HttpModule ......
public class FarFutureExpiresModule : IHttpModule
{
public void Dispose() { }
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, EventArgs e)
{
HttpContext context = HttpContext.Current;
string url = context.Request.Url.ToString();
if (url.Contains("/StaticContent/"))
{
context.Response.Cache.SetExpires(DateTime.Now.AddYears(30));
}
}
}
Run Code Online (Sandbox Code Playgroud)
虽然这看起来不起作用.我在代码上放置了一个断点,它可以正常运行.但是,当我在Firefox中分析原始HTTP标头信息时,未设置过期值.请注意我正在使用BeginRequest,但我也尝试连接到PostReleaseRequestState和PreSendRequestHeaders,它们似乎也不起作用.有任何想法吗?
更新2:好的,所以看起来因为我正在运行IIS6,HttpModules不会运行静态文件,只运行动态文件(*.aspx等).感谢RickNZ的帮助,我提出了以下IHttpModule:
public class FarFutureExpiresModule : IHttpModule
{
public void Dispose() { }
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, …Run Code Online (Sandbox Code Playgroud) 我想在单个服务中使用wshttpbinding(使用SSL而不使用SSL),但它不起作用,任何人都实现了它.那么请指导我如何实现这一目标?
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="CommonBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<serviceCertificate findValue="AzilenTechnology" x509FindType="FindBySubjectName" />
</serviceCredentials>
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig" closeTimeout="00:10:00"
openTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBindingConfig" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" bypassProxyOnLocal="true" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="CommonBehaviour" name="wcfAllInOne.wcfFileIO">
<endpoint binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<endpoint address="http://localhost:82/WCFAllInOne/wcfFileIO.svc/basicHttpEndPoint" binding="basicHttpBinding" …Run Code Online (Sandbox Code Playgroud)