Discuz! Tutorial on integrating NT 3 with asp.net

Source: Internet
Author: User

If the encoding is not rigorous, I hope you will forgive me and give me some pertinent comments.
Integration needs to be added to the original project by Discuz! Provided by NT
DiscuzToolkit Language Pack (c #)
In addition, to facilitate integration, I also wrote a simple project DNTAddNETSNS for Discuz! NT and SNS do some simple bonding.
Here are some code snippets related to API calls: Copy codeThe Code is as follows: // DNT integration code
Try
{
Discuz. Toolkit. DiscuzSession ds = ConformityHandler. InitDiscuzSession ();
Ds. Register (ConformityHandler. CreateDiscuzNTUsername (ui. Email), ui. Password, ui. Email, false );
Ret = User. Register (ui); // Register with sns to obtain registration information
}
Catch (Discuz. Toolkit. DiscuzException d)
{
If (d. ErrorCode = 109)
{
Ret = EnumRegister. EmailRepeat;
}
}
//

The above is an example of registering a user using methods in DiscuzToolkit. (Source code is in Register. aspx. cs)
For operations involving user security information, you need to obtain the AuthToken. To obtain the AuthToken, You need to request the Forum's login. aspx? Api_key = [key]. Then, the Forum will return an AuthToken to the configured Callback address in the form of GET. There are many places to use AuthToken during integration. However, only one callback address can be set, in this case, I created a new page dntapihandler. aspx, there is no content on this page. It is used only for callback transfer, that is, in Discuz! Set the callback address in NT to dntapihandler. aspx. Then, determine the final returned application Page Based on the next parameter.
Finally, we will list the pages that have been added with integrated code to help you read the source code.Copy codeThe Code is as follows: web. config
Global. asax
Register. aspx
User/default. aspx
Login. aspx
Logout. aspx
AccountSet. aspx
UserBase. aspx

Some of the above pages only change their. CS files, and some of them are modified.
To use this integration project, install and deploy it according to the SNS installation instructions. In addition, to Achieve Synchronous login (because SNS do not have APIs, the forum side cannot control SNS logon), you need to modify a Discuz! Nttemplate login.htm, add the following code in it.Copy codeThe Code is as follows: <% csharp %>
If (Request ["api_key"] = null & Request. Form ["username"]! = "Admin ")
Response. Redirect ([SNS logon page path ]);
<%/Csharp %>

Click to download source http://xiazai.jb51.net/200911/yuanma/dnt_netsns_src.zip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.