asp.net與Discuz!NT整合整合執行個體教程

來源:互聯網
上載者:User

但在網上沒有找到較詳細的描述。方法倒是有很多種。
在此,我就將此次經曆寫出來,希望對您有用。
在看過這篇文章
http://www.jb51.net/article/20851.htm
和這篇文章
http://www.jb51.net/article/20850.htm
按上述文章的描述,先按discuz!nt的使用者指南,在windows 2003下安裝好論壇。
並以admin進去,添加apikey等。
然後用VS2008建立一項目,添加toolkit.dll和json的引用。
好了, 如果你認真看過上述文章,再加上,我這兒貼的一點代碼,應該可以完成了。
在項目中註冊新使用者時,也同時調用論壇的使用者註冊,這樣就同步註冊了。至於刪除使用者,似乎Discuz!NT沒有提供API,可以在項目中刪除使用者時,再直接去刪除Discuz!NT的user表中的相關項目。
代碼(實現了登入和註冊)如下: 複製代碼 代碼如下:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Discuz.Toolkit;
namespace IntDNT3
{
public partial class _Default : System.Web.UI.Page
{
string api_key = "c83a253f082bc671d8fbe42d485a1488";
string secret = "bdb7378cef77149adec776b1b6e92ee8";
string url = "http://localhost/";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnValidation_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
Uri uri = ds.CreateToken();
Response.Redirect(uri.ToString());
}
protected void btnLogin_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
int uid = ds.GetUserID(tbUserName.Text);
ds.Login(uid, tbPWD.Text, false, 10, "");
}
protected void btnRegister_Click(object sender, EventArgs e)
{
DiscuzSession ds = new DiscuzSession(api_key, secret, url);
ds.Register("testa", "123123", "dafafa@51aspx.com", false);
}
}
}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.