asp.net與Discuz!NT整合集成實例教程
更新時間:2009年11月11日 00:58:52 作者:
由于項目需要一個論壇,本來有CS的,在.net下很出名的國外開源論壇。但為了適應(yīng)國內(nèi)的風(fēng)氣,最后選用在國內(nèi)如日中天的Discuz!NT。將Discuz與asp.net開發(fā)的網(wǎng)站整合,有很多人已經(jīng)完成了。
但在網(wǎng)上沒有找到較詳細(xì)的描述。方法倒是有很多種。
在此,我就將此次經(jīng)歷寫出來,希望對您有用。
在看過這篇文章
http://www.dbjr.com.cn/article/20851.htm
和這篇文章
http://www.dbjr.com.cn/article/20850.htm
按上述文章的描述,先按discuz!nt的用戶指南,在windows 2003下安裝好論壇。
并以admin進(jìn)去,添加apikey等。
然后用VS2008新建一項目,添加toolkit.dll和json的引用。
好了, 如果你認(rèn)真看過上述文章,再加上,我這兒貼的一點代碼,應(yīng)該可以完成了。
在項目中注冊新用戶時,也同時調(diào)用論壇的用戶注冊,這樣就同步注冊了。至于刪除用戶,似乎Discuz!NT沒有提供API,可以在項目中刪除用戶時,再直接去刪除Discuz!NT的user表中的相關(guān)項。
代碼(實現(xiàn)了登錄和注冊)如下:
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);
}
}
}
在此,我就將此次經(jīng)歷寫出來,希望對您有用。
在看過這篇文章
http://www.dbjr.com.cn/article/20851.htm
和這篇文章
http://www.dbjr.com.cn/article/20850.htm
按上述文章的描述,先按discuz!nt的用戶指南,在windows 2003下安裝好論壇。
并以admin進(jìn)去,添加apikey等。
然后用VS2008新建一項目,添加toolkit.dll和json的引用。
好了, 如果你認(rèn)真看過上述文章,再加上,我這兒貼的一點代碼,應(yīng)該可以完成了。
在項目中注冊新用戶時,也同時調(diào)用論壇的用戶注冊,這樣就同步注冊了。至于刪除用戶,似乎Discuz!NT沒有提供API,可以在項目中刪除用戶時,再直接去刪除Discuz!NT的user表中的相關(guān)項。
代碼(實現(xiàn)了登錄和注冊)如下:
復(fù)制代碼 代碼如下:
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);
}
}
}
相關(guān)文章
深入解析.NET 許可證編譯器 (Lc.exe) 的原理與源代碼剖析
許可證編譯器 (Lc.exe) 的作用是讀取包含授權(quán)信息的文本文件,并產(chǎn)生一個可作為資源嵌入到公用語言運(yùn)行庫可執(zhí)行文件中的 .licenses 文件2013-07-07ASP.NET:一段比較經(jīng)典的多線程學(xué)習(xí)代碼
ASP.NET:一段比較經(jīng)典的多線程學(xué)習(xí)代碼...2006-09-09asp.net中的check與uncheck關(guān)鍵字用法解析
這篇文章主要介紹了asp.net中的check與uncheck關(guān)鍵字用法,以實例形式較為詳細(xì)的分析了check與uncheck關(guān)鍵字的各種常見用法與使用時的注意事項,非常具有實用價值,需要的朋友可以參考下2014-10-10asp.net中MVC借助Iframe實現(xiàn)無刷新上傳文件實例
這篇文章主要介紹了asp.net中MVC借助Iframe實現(xiàn)無刷新上傳文件的方法,詳細(xì)分析了前端界面、回調(diào)函數(shù)與后臺處理的詳細(xì)流程,非常具有參考借鑒價值,需要的朋友可以參考下2014-12-12如何利用FluentMigrator實現(xiàn)數(shù)據(jù)庫遷移
這篇文章主要給大家介紹了關(guān)于如何利用FluentMigrator實現(xiàn)數(shù)據(jù)庫遷移的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04淺談ASP.NET MVC 防止跨站請求偽造(CSRF)攻擊的實現(xiàn)方法
下面小編就為大家分享一篇淺談ASP.NET MVC 防止跨站請求偽造(CSRF)攻擊的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01