|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
那做企业软件是不是最好用J2EE?asp.net|哀求明天做项目中举行https哀求时碰到如许的调试毛病,外部毛病:未能为SSL/TLS平安通道创建信托干系。毛病页面:依据考证历程,远程证书有效。经由剖析,在扫瞄器中翻开要举行一个平安确认。就是这个对话框引发的成绩。在网上搜了一下一样平常的办理举措,可是搜的内容对照少,如今在这里总结一下。
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingSystem.Net;
usingSystem.IO;
usingSystem.Text;
usingSystem.Net.Security;
usingSystem.Security.Authentication;
usingSystem.Security.Cryptography.X509Certificates;
publicpartialclass_Default:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
//for1.1在2.0下ServicePointManager.CertificatePolicy已过期
//ServicePointManager.CertificatePolicy=newAcceptAllCertificatePolicy();
//for2.0
//ServicePointManager.ServerCertificateValidationCallback=newSystem.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create("https://someurl");
request.Method="GET";
HttpWebResponseresponse=(HttpWebResponse)request.GetResponse();
StreamreceiveStream=response.GetResponseStream();
StreamReaderreadStream=newStreamReader(receiveStream,Encoding.UTF8);
Page.Response.Write(readStream.ReadToEnd());
response.Close();
readStream.Close();
}
//for2.0
publicboolCheckValidationResult(objectsender,X509Certificatecertificate,X509Chainchain,SslPolicyErrorserrors)
{//Alwaysaccept
returntrue;
}
//for1.1
internalclassAcceptAllCertificatePolicy:ICertificatePolicy
{
publicAcceptAllCertificatePolicy()
{
}
publicboolCheckValidationResult(ServicePointsPoint,System.Security.Cryptography.X509Certificates.X509Certificatecert,WebRequestwRequest,intcertProb)
{
//Alwaysaccept
returntrue;
}
}
}
在经过全球个人PC市场占有90%的微软对asp.net不断优化与整合后,asp.net与微软自身平台的动用上更加的高效,加上asp.net在应用上非常容易上手,相信asp.net仍会是最多客户选用的脚本语言,并会在未来几年继续领跑。 |
|