discuz! NT 3 and ASP.net integration of examples Tutorial _ practical skills

Source: Internet
Author: User
If there is an imprecise coding area, I hope you will forgive and give the pertinent advice.
Consolidation needs to be added to the original project by discuz! NT-Provided
Discuztoolkit Language Pack (C #)
In addition, in order to facilitate integration, I also wrote a simple project Dntaddnetsns, used to discuz! NT and SNS do some simple bonding.
Now let's show you some code snippets involving API calls:
Copy Code code as follows:

Integration code between the DNT
Try
{
Discuz.Toolkit.DiscuzSession ds = Conformityhandler.initdiscuzsession ();
Ds. Register (Conformityhandler.creatediscuzntusername (UI). Email), UI. Password, UI. Email, false);
ret = User.register (UI);//sns registration, obtaining registration information
}
catch (Discuz.Toolkit.DiscuzException D)
{
if (D.errorcode = 109)
{
ret = enumregister.emailrepeat;
}
}
//

The above is an instance of registering a user with a method in Discuztoolkit. (source code in Register.aspx.cs)
Involves the user's security information operation, needs to obtain the Authtoken, obtains the Authtoken to request the forum Login.aspx?api_key=[key], Then the forum will return to the set of callback address by a authtoken, the integration needs to use Authtoken place very much, but callback address can only set one, in response to this situation, I have created a new page dntapihandler.aspx, this page has no content, only used to do callback relay, that is, in discuz! The callback address is set to Dntapihandler.aspx in NT. The final application page is then determined based on the next parameter.
Finally listed to be added to the integration of the code page, easy to see the source.
Copy Code code as follows:

Web.config
Global.asax
Register.aspx
User/default.aspx
Login.aspx
Logout.aspx
Accountset.aspx
Userbase.aspx

As on the page some only changed its. CS files, some have modified.
If you want to use this consolidation project, you need to install the deployment according to the SNS installation instructions. and in order to achieve synchronous login (because SNS and no API, so the forum can not control SNS login), need to modify a discuz! NT Template login.htm, add the following code inside.
Copy Code code as follows:

<%csharp%>
If (request["Api_key"]==null&&request.form["username"]!= "admin")
Response.Redirect ("SNS login 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.