|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
asp对于服务器的要求较高,一般的服务器如果访问量一大就垮了,不得不重启。client|ip地点|serverInshort,theRemotingServercanmakeuseofSinkandSinkProvidertoretrievetheIPaddressoftheincomingrequest.TheIPaddressisavailableintheTransportHeadersoftheincomingmessage.AfterretrievingtheIPaddressintheSink,wesavetheIPaddresstotheCallContext,sothatitwillbeavailablelaterinthecodeexecutionpathaswell.Thefollowingsaresomebackgroundinformationregardingthetopics:
SinksandSinkChains
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconsinkssinkchains.asp
UsingCallContext
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingcallcontext.asp
CodemodifiedfromthesamplebyIngoRammer,authorof“Advanced.NetRemoting”:
usingSystem;
usingSystem.Collections;
usingSystem.IO;
usingSystem.Runtime.Remoting;
usingSystem.Runtime.Remoting.Messaging;
usingSystem.Runtime.Remoting.Channels;
usingSystem.Threading;
usingSystem.Net;
namespaceClassLibRemotingIPSink
{
publicclassClientIPServerSinkProvider:IServerChannelSinkProvider
{
privateIServerChannelSinkProvidernext=null;
publicClientIPServerSinkProvider(IDictionaryproperties,ICollectionproviderData)
{
}
publicvoidGetChannelData(IChannelDataStorechannelData)
{
}
publicIServerChannelSinkCreateSink(IChannelReceiverchannel)
{
IServerChannelSinknextSink=null;
if(next!=null)
{
nextSink=next.CreateSink(channel);
}
returnnewClientIPServerSink(nextSink);
}
publicIServerChannelSinkProviderNext
{
get{returnnext;}
set{next=value;}
}
}
publicclassClientIPServerSink:BaseChannelObjectWithProperties,IServerChannelSink,IChannelSinkBase
{
privateIServerChannelSink_next;
publicClientIPServerSink(IServerChannelSinknext)
{
_next=next;
}
publicvoidAsyncProcessResponse(System.Runtime.Remoting.Channels.IServerResponseChannelSinkStacksinkStack,System.Objectstate,System.Runtime.Remoting.Messaging.IMessagemsg,System.Runtime.Remoting.Channels.ITransportHeadersheaders,System.IO.Streamstream)
{
}
publicStreamGetResponseStream(System.Runtime.Remoting.Channels.IServerResponseChannelSinkStacksinkStack,System.Objectstate,System.Runtime.Remoting.Messaging.IMessagemsg,System.Runtime.Remoting.Channels.ITransportHeadersheaders)
{
returnnull;
}
publicSystem.Runtime.Remoting.Channels.ServerProcessingProcessMessage(System.Runtime.Remoting.Channels.IServerChannelSinkStacksinkStack,System.Runtime.Remoting.Messaging.IMessagerequestMsg,System.Runtime.Remoting.Channels.ITransportHeadersrequestHeaders,System.IO.StreamrequestStream,outSystem.Runtime.Remoting.Messaging.IMessageresponseMsg,outSystem.Runtime.Remoting.Channels.ITransportHeadersresponseHeaders,outSystem.IO.StreamresponseStream)
{
if(_next!=null)
{
IPAddressip=requestHeaders[CommonTransportKeys.IPAddress]asIPAddress;
Console.WriteLine(ip.ToString());
CallContext.SetData("ClientIPAddress",ip);
ServerProcessingspres=_next.ProcessMessage(sinkStack,requestMsg,requestHeaders,requestStream,outresponseMsg,outresponseHeaders,outresponseStream);
returnspres;
}
else
{
responseMsg=null;
</p>结论:和PHP一样,ASP简单而易于维护,很适合小型网站应用,通过DCOM和MTS技术,ASP甚至还可以完成小规模的企业应用,但ASP的致命缺点就是不支持跨平台的系统,在大型项目开发和维护上非常困难。 |
|