Header add

In this article we will see how to integrate Disqus plugin in .NET Core.

Now-a-days comments are the essential part of blogging or social world. Earlier we stored comments data in database/XML file. It is a big headache to handle the data maintenance and storage space. To overcome this, Disqus provide the comments plugin it is easy to use and it can install through if have basic knowledge in programming.

Disqus is a blog comment hosting service that offers a platform for social integration, social networking, user profiles, analytics, mobile commenting and so on.It is directly integrated with the most popular services like WordPress, Drupal, Wix etc..

Setup Disqus Plugin

Register in the Disqus Account in the link Disqus Signup Link


Sign up by using your email Id and password or you can signup using Facebook, Twitter or Google. You can see in many ways we add the Disqus forum such as  blogger,Wordpress , Wix etc..  We want to use Disqus integrate in our application so select install manually with Universal Code. For more details please see the link https://coreprogramm.disqus.com/admin/install/platforms/universalcode/

(i) The below code is use for integrate the Disqus

<div id="disqus_thread"></div>
<script>

/**
*  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
*  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://coreprogramm.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>                            
(ii) For displaying comment count need to add the below code
<script id="dsq-count-scr" src="//coreprogramm.disqus.com/count.js" async></script>
How to integrate the Disqus in .NET Core MVC application

Let's create a .NET Core MVC application and  check how to integrate Disqus Forum into it.

Step-1 : Open VS 2017 >> File New Project >> Choose .NET Core Web application

Choose Web application as MVC
Step-2 : Open the "Index.cshtml" and add the below div that append the Disqus panel
    <div id="disqus_thread"></div>
Step-3 : Add the below script in "Layout.cshtml"
     <script>  
         /**  
         * RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.  
         * LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/  
         /*  
         var disqus_config = function () {  
         this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable  
         this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable  
         };  
         */  
         (function () { // DON'T EDIT BELOW THIS LINE  
           var d = document, s = d.createElement('script');  
           s.src = 'https://coreprogramm.disqus.com/embed.js';  
           s.setAttribute('data-timestamp', +new Date());  
           (d.head || d.body).appendChild(s);  
         })();  
       </script>  
 After </body> tag add the below script.
    <script id="dsq-count-scr" src="//coreprogramm.disqus.com/count.js" async></script>
Run the application and you see that the Disqus Forum has been added our application.

Yup that's our requirement, you can see how easily we integrate Disqus forum in .NET Core application.
</> The Source Code is available in Github.com/CoreProgramm/


   Summary

In this tutorial we discussed how to Disqus Plugin Integration in .NET Core. If have any question related to this topic then give your feedback.

Post a Comment

Previous Post Next Post