asp.net自动登录 能实现的请帮忙下

lizhao861018 2010-03-04 10:13:46
求asp.net自动登录网站https://www.chinasup.cn/ ,然后获取登录后的页面的源代码,需要什么请联系我
QQ:365824476
...全文
176 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
ajbj00 2010-03-06
  • 打赏
  • 举报
回复
路过,学习!!!

回复太短,补充字数
prettykill 2010-03-06
  • 打赏
  • 举报
回复
顶一楼。细看之(字数补丁)
lizhao861018 2010-03-05
  • 打赏
  • 举报
回复
谢谢帮顶,但求实用回复,终能解决问题
lanjian0819 2010-03-05
  • 打赏
  • 举报
回复
路过,学习!!!

回复太短,补充字数
lubosun 2010-03-05
  • 打赏
  • 举报
回复
这个问题不错,帮顶一下

实际上CSDN也有这种功能,只不过更强一些,还能自动删除
lizhao861018 2010-03-05
  • 打赏
  • 举报
回复
我可以提供用户名跟密码 供测试
lizhao861018 2010-03-05
  • 打赏
  • 举报
回复
不行哦 一楼的 我测试不通过哦
daichenghua 2010-03-05
  • 打赏
  • 举报
回复
..................................
gelinbod 2010-03-05
  • 打赏
  • 举报
回复
这个似乎对我有用,也顺便研究一下
Im_Sorry 2010-03-05
  • 打赏
  • 举报
回复
..................................
netajax1 2010-03-05
  • 打赏
  • 举报
回复
每天回帖得10分。。。。。。。。。
readfuture 2010-03-04
  • 打赏
  • 举报
回复
Dream_Hunter_ 2010-03-04
  • 打赏
  • 举报
回复
请问楼主什么叫“需要什么,请联系我。。。”
cpp2017 2010-03-04
  • 打赏
  • 举报
回复
HttpWebRequset
1、通过附加一个cookiecontainer到httprequest对象中,可以得到登录后返回的代表SESSION ID的COOKIE。

2 、将此COOKIE包含在一个cookiecontainer中并附加到另一个HTTPREQUEST请求中,则可以实现SESSION的还原。

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
//using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Data.Odbc;
namespace PdfTest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class getHttpInfo : System.Web.UI.Page
{
protected static string cookieheader;


private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

string strResult;

if (HttpContext.Current.Application["cookieheader"] != null)
{
cookieheader = (string)HttpContext.Current.Application["cookieheader"];
}
else
{
//Login into the website and keep the cookie for the session in the application variable
string strLogin = Login("http://www.thesiteyouwanttovisit/theloginpage.asp", "Action=&USERID=&Password=") ;
}


strResult = getPage("http://www.thesiteyouwanttovisit/theloginpage.asp", "Action=&data=") ;


//Write the result to htm file
FileStream htmFile = new FileStream("c:\save.htm", FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(htmFile);
sw.Write(strResult);
sw.Close();
htmFile.Close();

// output the result
Response.Write(strResult);
}


public static string Login(String url, String paramList)
{
HttpWebResponse res = null;
string strResult="";

try
{

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.AllowAutoRedirect = false;
CookieContainer cookieCon = new CookieContainer();
req.CookieContainer = cookieCon;

StringBuilder UrlEncoded = new StringBuilder();
Char[] reserved = {'?', '=', '&'};
byte[] SomeBytes = null;

if (paramList != null)
{
int i=0, j;
while(i<paramList.Length)
{
j=paramList.IndexOfAny(reserved, i);
if (j==-1)
{
UrlEncoded.Append(HttpUtility.UrlEncode(paramList.Substring(i, paramList.Length-i)));
break;
}
UrlEncoded.Append(HttpUtility.UrlEncode(paramList.Substring(i, j-i)));
UrlEncoded.Append(paramList.Substring(j,1));
i = j+1;
}
SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
req.ContentLength = SomeBytes.Length;
Stream newStream = req.GetRequestStream();
newStream.Write(SomeBytes, 0, SomeBytes.Length);
newStream.Close();
}
else
{
req.ContentLength = 0;
}


res = (HttpWebResponse)req.GetResponse();
cookieheader = req.CookieContainer.GetCookieHeader(new Uri(url));
HttpContext.Current.Application.Lock();
HttpContext.Current.Application["cookieheader"] = cookieheader;
HttpContext.Current.Application.UnLock();

Stream ReceiveStream = res.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader sr = new StreamReader( ReceiveStream, encode );
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 );
while (count > 0)
{
String str = new String(read, 0, count);
strResult += str;
count = sr.Read(read, 0, 256);
}
}
catch(Exception e)
{
strResult = e.ToString();
}
finally
{
if ( res != null )
{
res.Close();
}
}

return strResult;
}


public static string getPage(String url, String paramList)
{
HttpWebResponse res = null;
string strResult = "";

try
{

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.KeepAlive = true;
req.ContentType = "application/x-www-form-urlencoded";
CookieContainer cookieCon = new CookieContainer();
req.CookieContainer = cookieCon;
req.CookieContainer.SetCookies(new Uri(url),cookieheader);
StringBuilder UrlEncoded = new StringBuilder();
Char[] reserved = {'?', '=', '&'};
byte[] SomeBytes = null;

if (paramList != null)
{
int i=0, j;
while(i<paramList.Length)
{
j=paramList.IndexOfAny(reserved, i);
if (j==-1)
{
UrlEncoded.Append(HttpUtility.UrlEncode(paramList.Substring(i, paramList.Length-i)));
break;
}
UrlEncoded.Append(HttpUtility.UrlEncode(paramList.Substring(i, j-i)));
UrlEncoded.Append(paramList.Substring(j,1));
i = j+1;
}
SomeBytes = Encoding.UTF8.GetBytes(UrlEncoded.ToString());
req.ContentLength = SomeBytes.Length;
Stream newStream = req.GetRequestStream();
newStream.Write(SomeBytes, 0, SomeBytes.Length);
newStream.Close();
}
else
{
req.ContentLength = 0;
}


res = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = res.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader sr = new StreamReader( ReceiveStream, encode );
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 );
while (count > 0)
{
String str = new String(read, 0, count);
strResult += str;
count = sr.Read(read, 0, 256);
}
}
catch(Exception e)
{
strResult = e.ToString();
}
finally
{
if ( res != null )
{
res.Close();
}
}

return strResult;
}


#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion



}
}






本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/brightview/archive/2005/12/21/558141.aspx
使用IIS承载WCF服务版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/xunzaosiyecao/article/details/47065199 作者:jiankunking 出处:http://blog.csdn.net/jiankunking 1、WCF可以方便的通过IIS承载,此承载模型与ASP.NETASP.NET Web Service使用的模型类似。 2、WCF可以在以下操作系统上的IIS版本上承载 Windows XP SP2上的IIS 5.1 Windows Server 2003上的IIS 6.0 Windows Server 2008或者Windows Vista或者Windows 7上的IIS 7.0 以及IIS后续版本 小注: 3、在IIS 7.0中提供了一种新的承载服务方式即WAS(Windows Process Activation Service,Windows进程激活服务),使用WAS来承载WCF允许HTTP之外的协议进行激活和网络通信。此环境适合开发可通过WCF支持的任何网络协议(包括HTTP、net.tcp、net、.pipe和net.msmq)进行通信的WCF服务。 在WAS宿主中,可以使用WAS工作进程中的功能,如自动激活服务、健康监控和进程。 要使用WAS宿主,只需创建一个Web站点和工个.svc文件,其中的ServiceHost声明包含服务类的语言和名称。 下面的代码使用 Service1类。另外,还必须指定包含服务类的文件。这个类的实现方式与定义WCF服务库的方式相同。  这不就是平时部署的.svc文件嘛 例如: 4、使用IIS承载的好处: 可以向处理其他任何类型的IIS应用程序一样,部署和管理IIS中承载的WCF服务。 IIS提供进程激活、运行状态管理和回收功能以提高承载的应用程序的可靠性。 像ASP.NET一样,ASP.NET中承载的WCF服务可以利用ASP.NET共享宿主模型,在此模型中,多个应用程序驻留在一个公共辅助进程中以提高服务器密度和可伸缩性。 IIS中承载的WCF服务与ASP.NET2.0使用相同的动态编译模型,该模型简化了承载服务的开发和部署。 IIS承载WCF服务时,IIS5.1和IIS6.0仅限于HTTP通信。 5、WCF具体写法及部署与IIS在此就不重复演示,具体案例可以参考: WCF 部署在IIS上 WCF 入门教程一(动手新建第一个WCF程序并部署) WCF 入门教程二 小注: 1、个人感觉有了锤子就没必要用手敲钉子了,所以搞WCF的时候,使用Visual Studio吧,没必要用文本文件去创建svc等等的文件。 比如说客户端应用程序需要 一 个代理来访问服务。给客户端创建代理就有3种方式 : ● Visual Studio添加服务引用 —— 这个实用程序会从服务的元数据中创建代理类。 ● ServiceModel元数据实用工具svcutil.exe —— 使用svcutil实用程序可以创建代理类。该实用程序从服务中读取元数据 ,以创建代理类。 ● ChanneldFactory类 —— 这个类由svcutil实用程序生成的代理使用 ,然而,它也可以用于以编程方式创建代理。         个人还是感觉 Visual Studio比较自动化一些 2、据说部署WCF,需要激活WCF HTTP激活组件,具体激活方式如下: 安装完成后,可以在:IIS管理器----处理程序映射中看到:svc-Integrated 项,说明安装成功了 但是有个问题就是,我部署WCF时候,么有激活这个服务,为啥WCF也能运行呢?希望有知道的朋友帮忙解答一下,谢谢。 ———————————————— 版权声明:本文为CSDN博主「衣舞晨风」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/jiankunking/article/details/47065199

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧