DotNetNuke Hosting with ASPHostPortal.com

BLOG about DotNetNuke CMS, latest technology and Special DotNetNuke Hosting Package with ASPHostPortal.com

DotNetNuke Hosting - ASPHostPortal.com :: How To Develop Web Service in DNN

clock January 12, 2017 04:49 by author Armend

I have recently been assigned to built a DotNetNuke web service to permit a windows application (or any sort of net client for instance) the flexibility to control DotNetNuke person accounts (create, change roles, delete, retrieve e mail address, and so forth.).

Since I had a tough time locating an accurate code sample or documentation that really applies to DotNetNuke and accessing it without having being earlier logged in to DotNetNuke, it absolutely was difficult to constructed anything at all. I ultimately found out how to do it properly so I hard I would put my attempts to some use and write a blog publish explaining how you can get it done step by stage.

 


That said, let's begin by the fundamentals and just create a publicly available web services that permits anybody to ping the net service and acquire a pong again. For that we are going to use the new DotNetNuke 7 Providers Framework which makes it fairly simple should you know how to utilize it.

In order to create a net support that will work within DotNetNuke 7, you will need to fireplace up Visual Studio and create a class Library project (c# or VB but all illustrations listed here will be in c#).

That done, we will then reference some needed DotNetNuke 7 required libraries (making use of the Add Reference dialog box), here's the list:

DotNetNuke.dll
DotNetNuke.Web.dll
System.Net.Http.dll
System.Net.Http.Formatting.dll
System.Web.Http.dll

Then we also need to reference the System.Web class from the .NET tab of the same dialog box.

Finally, we neet to set the output path of the project to the DotNetNuke bin directory and we are ready to code.

Here is the code, the explanations follow:

using System.Net;
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Web.Api;
 
namespace MyService
{
    public class PingController : DnnApiController
    {
        [AllowAnonymous]
        [HttpGet]
        public HttpResponseMessage PublicPing()
        {
            return Request.CreateResponse(HttpStatusCode.OK, "Pong!");
        }
    }
 
    public class RouteMapper : IServiceRouteMapper
    {
        public void RegisterRoutes(IMapRoute mapRouteManager)
        {
            mapRouteManager.MapHttpRoute("MyService", "default", "{controller}/{action}", new[]{"MyService"});
        }
    }
}

  1. We merely start with some using statements for our needs as demonstrated previously mentioned
  2. We develop a namespace for our service and no matter what name we use listed here will be part of the url. I utilized MyService just for this instance but use any name which makes perception for your services.
  3. Now we create a public class for our controller. You'll be able to create numerous controllers if you want to and the controller is just a bunch of related actions that make feeling to group with each other. In my genuine project I have a PingController for testing functions, a UsersController for almost any steps that relate to user accounts and so forth. Just utilize a identify that makes feeling because it will even present up in the url. Two things for being careful right here:

    • The identify of one's controller should end using the term Controller but only what will come just before it will show inside the url, so for PingController, only Ping will show in the url route.
    • It should inherit DnnApiController so it'll use the DotNetNuke Providers Framework.
  4. Then we create the actual motion, inside our case, PublicPing. It's just a straightforward technique which return an HttpResponseMessage and may have a handful of characteristics. By default the brand new providers framework will respond only to host consumers and you also must explicitly enable other access rights if necessary, in this case the [AllowAnonymous] helps make this technique (or action if you prefer) obtainable to anyone with out credentials. The next attribute, [HttpGet] can make this action reply to HTTP GET verb, which can be usually used when requesting some date in the web server.
  5. Finally in that action, you insert whatever code you action needs to do, in this case just return the string "Pong!", just remember that you should return an HttpResponseMessage rather than a string or int or other item.

Ok so our controller and motion is done, now we just need to map that to an actual URL and that exactly what the final portion of the earlier code does. In essence this code tells DotNetNuke to map a specific url pattern for the techniques outlined in your course. You can use that code as is simply replacing MyService by no matter what your support title is.

Testing:
That is all there is certainly to it, your services is prepared! To test it, first compile it, then just navigate to http://yourdomain/DesktopModules/MyService/API/Ping/PublicPing and you should see "Pong!" inside your browser like a response.

Passing parameters

Ok, so the basic code above is working but it doesn't do anything useful. Lets add something more useful by creating an action that will give us the email address for a specific user id.

Again, here's the code and the explanations will follow (place the code inside the same namespace as the previous one):

public class UsersController : DnnApiController
    {
        [RequireHost]
        [HttpGet]
        public HttpResponseMessage GetEmail(int userid)
        {
            DotNetNuke.Entities.Users.UserInfo ui;
            ui = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, userid);
            return Request.CreateResponse(HttpStatusCode.OK, ui.Email);
        }
    }


Initial we build a UsersController course which will hold all actions related to person accounts, it isn't completely required, you'll be able to have numerous steps within the same controller, nonetheless because this motion is not in any respect connected to our PingController, let'a create a new one more descriptive.

We then create a GetEmail motion (method) which will accept a userid parameter. The [RequireHost] parameter listed here will make it accessible only to host customers, we are going to see afterwards other authentication options.

The code inside the approach alone is fairly significantly self explanatory. The only interesting factor to notice listed here is the fact that because our course inherits DnnApiController, we already have a PortalSettings item obtainable. That is the big benefit of producing use of the DotNetNuke Solutions Framework. You'll have a ModuleInfo object to represent your module (if there is 1 using the identical identify as your support, which can be not essential such on this scenario), a PortalSettings object that signifies the portal at the domain title utilized to accessibility the support (portal alias) and at last a UserInfo item symbolizing the person that accessed the web services.

Testing:

If we now navigate to http://yourdomain/MyService/API/Users/GetEmail?userid=2 you need to receive the email tackle back again from the server unless of course obviously that userid does not exist, ensure that you check having a userid that truly exists for that portal. Should you exactly where not formerly linked having a host account, you then will probably be requested for qualifications.

Limiting access to particular roles

Alright, that actually works however, you need to give host qualifications to anyone needing to make use of your webservice. To avoid which you can change [RequireHost] by [DnnAuthorize(StaticRoles="Administrators")] which can limit access to administrators. Much better however, you nevertheless must provide them with an admin account. So the easy method to give only constrained entry would be to create a brand new role in DotNetNuke only for your internet services and substitute Administrators by that specific function title within the authentication parameter.

Utilizing HttpPost : (reply to a comment down bellow)

To answer Massod comment bellow, it's nearly exactly the same thing however, you have to develop an object to contain the posted information.

Let's make a easy ping that makes use of Submit, very first we need to create an object which will contain the posted info this sort of as:

public class FormMessage
    {
        public string Message { get; set; }
    }

Then we create the service method something like this:

 

public class PingController : DnnApiController
   {
       [AllowAnonymous]
       [HttpPost]
       public HttpResponseMessage PostPing(FormMessage formMessage)
       {
           return Request.CreateResponse(HttpStatusCode.OK, "Pong from POST: message was '" + formMessage.Message + "'.");
       }
   }

note that normally, a post would only return ok and no message, I am just doing this so we can test here.

Now since this is a POST verb, we can't test it by only using url parameters, we need to make an html file with a form to test it out. It would be someting like this:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Pagetitle>
head>
<body>
    <form action="http://dnndev/DesktopModules/MyService/API/Ping/PostPing" method="POST">
        <label for="message">Message: label><input type="text" name="Message"/>
        <input type="submit" value="Submit"/>
    form>
body>
html>

The crucial thing to not right here is you can not just develop your Publish technique taking a string even when this can be only what you require, you do must create an object which will get your parameters.

Also never overlook that this is only for tests, you usually do not need to make this publicly accessible, you'd probably usually use yet another parameter than [AllowAnonymous] such as [DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.View)] and [ValidateAntiForgeryToken] unless you truly want that for being public.

 

Best DotNetNuke Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers DotNetNuke hosting starts from $5/month only. We also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable DotNetNuke Hosting, we should be your best choice.



DotNetNuke Hosting - ASPHostPortal.com :: Optimization SEO in DotNetNuke

clock January 5, 2017 04:58 by author Armend

DotNetNuke has many SEO features, but some are less obvious to the casual administrator. These SEO features, however, can have a dramatic effect on how your DNN website is indexed by Google, Bing and others, and as such, can have an effect on your page rank and search results.

 

Here are a few DNN tips and tricks to help in your DNN’s SEO:

1. Site Map Priority

Buried within your page settings is a feature that allows you to set indexing priorities to your DNN pages. To get there (once logged in as an administrator), go to “page settings”, then “advanced settings”, then at the bottom of the window, go to “other settings”.

Here you will find the item: “Site Map Priority”. The default for this is .5. However, if your page is the home page, or perhaps a landing page, you will want to up the number to 1.0, or .9 (1.0 being the highest). This will increase the perceived importance of the page by search engines such as Google. Where is this relevant? When your organization appears in a Google search, high priority pages may be presented as sub-links to the home page more frequently. This can be critical in immediately directing visitors to key pages in an organic search result.

2. Site Settings

Here we’ll talk about one of things NOT to do when it comes to SEO in DotNetNuke. In the “site settings” of DotNetNuke, administrators have the ability to enter descriptions and keywords. By doing that, those items will then be placed in the META tags for EVERY page on the DNN website. For SEO, this is an extreme no-no, as it will confuse the search engines and reduce the relevancy and page rank of your overall DNN website. It may be an easy way to get keywords throughout your site… but it will definitely hurt you in the long run!

3. Page Titles

One of the nice features about DotNetNuke is its ability to add dashes between spaced words in your page title. For example, if you title a page “DNN SEO Tips”, DNN will title the actual URL as “DNN-SEO-Tips”. This ensures that the individual words in the title will be relevant to Google.
Some administrators like to use underscores between words. For example: “DNN_SEO_Tips”. This is strongly discouraged as Google will index the entire string as one item. This means people searching for DNN, or SEO or Tips will not see your site on Google. They would only find you if they specifically put “DNN SEO Tips”. In some cases this may be a good thing, if your content is very niche-oriented. But if you’re looking to gather visitors based on more broad searches, using underscores will hurt you.

4. Robots.txt

OK, this one gets a bit technical for the casual DotNetNuke administrator, but robots.txt is an important factor when comes to SEO, so what we’ll do in this section is give you enough information that you can intelligently go to your IT person or your hosting provider to ask questions.

In short, the robots.txt function (which not accessible via the administration tools in DNN), tells various search engines such as Google what pages to index and what pages they should not. Pretty important! But, if your DNN website is with a host provider and you are operating on a shared instance (one installation of DNN with many portals), you may be operating on one, centralized robots.txt file, which may be configured to tell the robots to ignore all pages on your site!

There is a way to take control and get around this, but it takes someone with access to the server and a bit of IT knowledge. But, don’t let that stop you from finding out if your robots.txt file is configured properly.

  • Ask your IT or host provider:
  • Is your DNN website on a shared instance?
  • Do you have an individual robots.txt file for your specific DNN website?

That’s it a few simple tools and information on how to squeeze more effectiveness with your DotNetNuke’s SEO. Hope useful.

Best DotNetNuke Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers DotNetNuke hosting starts from $5/month only. We also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable DotNetNuke Hosting, we should be your best choice.



DotNetNuke Hosting - ASPHostPortal.com :: How To Improvement Performance in DNN

clock December 22, 2016 04:46 by author Armend

I have been seeing a big number of concerns not too long ago with regards to DotNetNuke functionality and items that will be done to help improve the overall performance in the internet site. Usually these questions surround the SiteLog and EventLog tables so I thought I'd post a number of simple queries which you can run to assist hold your database lean that will preserve your DotNetNuke website running at peak efficiency.

Website Log

I'll start off using the Internet site Log table, the website log functionality isn't a single that I truly utilize in my site, nonetheless for all those of you who use it in yours you are going to need to hold an eye on it, I have noticed that right after the log has grown to more than about 4-5 thousand records that you could begin to notice some efficiency decreases. Furthermore if you're like myself and have turned off the internet site log I found out that it will not necessarily clean itself up in case you turned it off, therefore in my case I had 1000 lingering records, which just unnecessarily improved the size of my database.

To check the amount of records within your Site Log use the following query

SELECT Count(*)
FROM SiteLog

To find the oldest record in the site log use the following

SELECT MIN([DateTime])
FROM SiteLog

Soon after you've viewed this details you can establish your necessary course of action. In my case since the internet site log is disabled on all portals I simply deleted all records in the table employing a basic delete statement. Within your case you could only want to purge certain records but that determination is outdoors the scope of this short article.

Event Log

The Occasion log shops portal certain event details like logins, invalid login attempts and actual errors. If you have a pretty active portal this table can grow very big really quickly. For my sites with their visitors of about 100-120 guests per day I have noticed an EventLog of over 2000 records within a two.five month period. Now unless you happen to be auditing logins or undertaking particular tracking you are able to normally rid yourself of those records without much impact. You'll be able to purge these portal by portal via the "Event Viewer" inside DotNetNuke, or it is possible to view and modify records by way of the database. Beneath I'll give you two valuable queries.

To determine the number of records, as well as the quantity of records per portal. Note, inside the benefits in the per portal query, you are going to discover a lot of entries listed having a NULL portal id, that is for DNN installation wide things, like scheduler and application events.

--Overall total
SELECT COUNT(*)
FROM EventLog

--Total by portal (null is not portal specific)
SELECT LogPortalId, COUNT(*)
FROM EventLog
GROUP BY logPortalId

To identify the oldest records you can use one of the following queries, again an overall minimum and a per portal minimum will be found

SELECT MIN(LogCreateDate)
FROM EventLog

SELECT LogPortalId, MIN(LogCreateDate)
FROM EventLog
GROUP BY logPortalId

Once again for deleting these records the decision truly depends upon your portals use on the Occasion Log and any require for user login auditing. In my case I once again don't require this details and at present I've resolved all of my routine errors that had been taking place, for that reason I removed all records in my listing across all sites. I try to complete this at the very least as soon as as month to ensure that the table size has been decreased.

Viewing DB Size

If you would like to view the size of one's database files you are able to make use of the query below to view the size of every single file for the present database.

SELECT *
from SYSFILES

Making use of these ideas you'll be able to start to acquire a better understanding of the database size and you can assist handle it and preserve your DotNetNuke website running at peak efficiency!

Best DotNetNuke Hosting Recommendation

ASPHostPortal.com
ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers DotNetNuke hosting starts from $5/month only. We also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable DotNetNuke Hosting, we should be your best choice.



DotNetNuke Hosting - ASPHostPortal.com :: Tips To Integrate DNN with SharePoint 2013

clock December 15, 2016 05:25 by author Armend

DotNetNuke has already established itself as 1 from the most well-liked too as preferred net content management systems, primarily based on Microsoft. Net. DotNetNuke web sites are identified to provide outstanding user knowledge while also letting the brands enhance their identity. The current trend is the fact that of integrating this content material management system with that of Microsoft SharePoint, of which the newest version has not too long ago come out within the form of SharePoint 2013.


The integration is really valuable for the companies inside a number of methods. Right here is really a short overview of how the integration of DotNetNuke with SharePoint can be executed with accomplishment.

Powerful Document Management with SharePoint

SharePoint is undoubtedly probably the most preferred at the same time as even sought- after program for document management, helpful for businesses of varying size or nature. Now, this platform is constructed into cloud, which allows maximum storage and accessibility. Consequently, the experts in a group have an chance to share as well as collaborate on apparently massive amounts of data and documents. Moreover, the platform integrates efficiently with Outlook and this enables enhancement in the significance on the social tools. All this results in a very carefully organized atmosphere. The group members can also convert the raw data into critical interactive reports.

Integration of DotNetNuke with SharePoint

The top thing about integrating the web content management method together with the net application improvement platform is the fact that the two of them integrates quite seamlessly. An automatic integration implies that no additional efforts are essential when it comes to operating the method. The DNN Neighborhood can merge together with the platform inside a rather hassle- totally free manner by indicates of using the custom modules. The primary thought, here, is always to design and style a method that enables the platform to communicate from behind a firewall with all the folks facing the website. Now, all this implies that the documents could be pushed in to the portal around the DotNetNuke website with larger degree of safety and efficiency. Simultaneously, the filter rules can be made to track down the individual documents to discover as to exactly where they go.

DNN Enterprise and SharePoint Connector

In situations where the platform is utilized as the document management program, integration of the identical with DotNetNuke Enterprise Edition is really of real rewards. The custom integration saves a lot of income in the enterprise while investment that is produced is actually worthy.

The DNN Enterprise SharePoint connector comes up as a powerful and considerable function, supporting each 2007 and 2010 versions of the platform. The firewall problems can be avoided at the same time. Content, around the other hand, stays fresh and is published directly from the SharePoint Document Library. It is the DotNetNuke role- based security network that performs the crucial function of safeguarding the published documents.

Generating Use on the SharePoint Folder Provider

The SharePoint Folder is particularly beneficial in integration with DotNetNuke 6. It enables the DNN customers to store at the same time as synchronize the files contained inside the document libraries, located in 2010 version of this platform.

Here is an overview on the characteristics of this Folder as well as the way it aids:

The communication amongst the net application improvement platform and the DotNetNuke six becomes more rapidly and more direct by virtue from the folder. It paves the way for a number of providers to indicate to different document libraries from either the equivalent platform based internet sites or in the various ones.

The SharePoint Folder facilitates quite a few functionalities such as addition cum deleting of folders, uploading, downloading, renaming of files as well as synchronization of the files and folders. Above all, this Folder really acts as a powerful base for numerous DNN modules, which make use on the DotNetNuke file technique. Custom SharePoint development teams can help you build projects within allocated budgets and time schedules.

Best DotNetNuke Hosting Recommendation

ASPHostPortal.com is the leading provider of Windows hosting and affordable DotNetNuke Hosting. DotNetNuke Hosting from ASPHostPortal.com provides a safe, reliable and performance-driven foundation for your DotNetNuke website. DotNetNuke is the perfect Content Management System for managing and developing your website with one of ASPHostPortal’s Hosting plans. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.



DotNetNuke Hosting - ASPHostPortal.com :: Tips To Remove .aspx from DNN

clock December 8, 2016 05:05 by author Armend

In this post I will expains how to remove .aspx from DotNetNuke URL, Lets check it out. DotNetNuke ships with a URL supplier that throughout the years has experienced a few overhauls by they way it can deal with URLs

 

Unique Method – Default.aspx?TabId=52

Second Version –/Home/TabId/52/Default.aspx

Human Friendly (Current Default) –/Home.aspx

The new human cordial is extraordinary yet obliges that the client attach the .aspx to the end of the page names.

Contextual analysis

Lets say you have a business card or advancement and you need to promote a particular page on your site that individuals could really sort in

"www.domain.com/promo"

Regularly what you would do is FTP into your DotNetNuke root index, make an organizer called promo and afterward make a default.htm page to divert to www.domain.com/promo.aspx

Reworking the URL

With IIS7 and Url Rewriting you can now add a few lines to your web.config record and handle urls without the .ASPX augmentation. The following is a sample of such a modify principle and you will put this within your hub.

<rewrite>
    <rules>
        <rule name="sanitize aspx">
          <match url="(^.*)" />
          <conditions logicalGrouping="MatchAll">
            <add negate="true" input="{REQUEST_FILENAME}" matchType="IsFile" />
            <add negate="true" input="{REQUEST_FILENAME}" matchType="IsDirectory" />
            <add input="{URL}" pattern="(.*).(.*)" negate="true" />
          </conditions>
          <action url="{R:1}.aspx" type="Rewrite" />
        </rule>
    </rules>
</rewrite>


This code lives up to expectations by first verifying that a document or index with the/promo does not as of now exist. On the off chance that it does then the physical record will overshadow the change guideline. Second it will then take the area url and add the .aspx to the end on the off chance that it doesn't exist. So when you write in/promo in the background it is serving up the page/promo.aspx. This is carried out without diverting or changing the url.

Presently all your URLs in DotNetNuke can be straightforward and considerably all the more beautiful.

Here is an option form in the event that you need to do 301 sidetracks to the page name versus revamping the url.

<rewrite>
    <rules>
        <rule name="sanitize aspx" stopProcessing="true">
          <match url="(^.*)" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{URL}" pattern="(.*).(.*)" negate="true" />
          </conditions>
          <action type="Redirect" url="{R:1}.aspx" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>

Best DotNetNuke Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers DotNetNuke hosting starts from $5/month only. We also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable DotNetNuke Hosting, we should be your best choice.



DotNetNuke Hosting - ASPHostPortal.com :: How To Build Webservice in DNN

clock December 1, 2016 07:32 by author Armend

I have recently been assigned to built a DotNetNuke web service to permit a windows application (or any sort of net client for instance) the flexibility to control DotNetNuke person accounts (create, change roles, delete, retrieve e mail address, and so forth.).


Since I had a tough time locating an accurate code sample or documentation that really applies to DotNetNuke  and accessing it without having being earlier logged in to DotNetNuke, it absolutely was difficult to constructed anything at all. I ultimately found out how to do it properly so I hard I would put my attempts to some use and write a blog publish explaining how you can get it done step by stage.


That said, let's begin by the fundamentals and just create a publicly available web services that permits anybody to ping the net service and acquire a pong again. For that we are going to use the new DotNetNuke 7 Providers Framework which makes it fairly simple should you know how to utilize it.

In order to create a net support that will work within DotNetNuke 7, you will need to fireplace up Visual Studio and create a class Library project (c# or VB but all illustrations listed here will be in c#).

That done, we will then reference some needed DotNetNuke 7 required libraries (making use of the Add Reference dialog box), here's the list:

DotNetNuke.dll
DotNetNuke.Web.dll
System.Net.Http.dll
System.Net.Http.Formatting.dll
System.Web.Http.dll

Then we also need to reference the System.Web class from the .NET tab of the same dialog box.

Finally, we neet to set the output path of the project to the DotNetNuke bin directory and we are ready to code.

Here is the code, the explanations follow:

using System.Net;
using System.Net.Http;
using System.Web.Http;
using DotNetNuke.Web.Api;
 
namespace MyService
{
    public class PingController : DnnApiController
    {
        [AllowAnonymous]
        [HttpGet]
        public HttpResponseMessage PublicPing()
        {
            return Request.CreateResponse(HttpStatusCode.OK, "Pong!");
        }
    }
    public class RouteMapper : IServiceRouteMapper
    {
        public void RegisterRoutes(IMapRoute mapRouteManager)
        {
            mapRouteManager.MapHttpRoute("MyService", "default", "{controller}/{action}", new[]{"MyService"});
        }
    }
}

  1. We merely start with some using statements for our needs as demonstrated previously mentioned
  2. We develop a namespace for our service and no matter what name we use listed here will be part of the url. I utilized MyService just for this instance but use any name which makes perception for your services.
  3. Now we create a public class for our controller. You'll be able to create numerous controllers if you want to and the controller is just a bunch of related actions that make feeling to group with each other. In my genuine project I have a PingController for testing functions, a UsersController for almost any steps that relate to user accounts and so forth. Just utilize a identify that makes feeling because it will even present up in the url. Two things for being careful right here:

    • The identify of one's controller should end using the term Controller but only what will come just before it will show inside the url, so for PingController, only Ping will show in the url route.
    • It should inherit DnnApiController so it'll use the DotNetNuke Providers Framework.
  4. Then we create the actual motion, inside our case, PublicPing. It's just a straightforward technique which return an HttpResponseMessage and may have a handful of characteristics. By default the brand new providers framework will respond only to host consumers and you also must explicitly enable other access rights if necessary, in this case the [AllowAnonymous] helps make this technique (or action if you prefer) obtainable to anyone with out credentials. The next attribute, [HttpGet] can make this action reply to HTTP GET verb, which can be usually used when requesting some date in the web server.
  5. Finally in that action, you insert whatever code you action needs to do, in this case just return the string "Pong!", just remember that you should return an HttpResponseMessage rather than a string or int or other item.

Ok so our controller and motion is done, now we just need to map that to an actual URL and that exactly what the final portion of the earlier code does. In essence this code tells DotNetNuke to map a specific url pattern for the techniques outlined in your course. You can use that code as is simply replacing MyService by no matter what your support title is.

Testing:

That is all there is certainly to it, your services is prepared! To test it, first compile it, then just navigate to http://yourdomain/DesktopModules/MyService/API/Ping/PublicPing and you should see "Pong!" inside your browser like a response.

Passing parameters

Ok, so the basic code above is working but it doesn't do anything useful. Lets add something more useful by creating an action that will give us the email address for a specific user id.

Again, here's the code and the explanations will follow (place the code inside the same namespace as the previous one):

public class UsersController : DnnApiController
    {
        [RequireHost]
        [HttpGet]
        public HttpResponseMessage GetEmail(int userid)
        {
            DotNetNuke.Entities.Users.UserInfo ui;
            ui = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, userid);
            return Request.CreateResponse(HttpStatusCode.OK, ui.Email);
        }
    }

Initial we build a UsersController course which will hold all actions related to person accounts, it isn't completely required, you'll be able to have numerous steps within the same controller, nonetheless because this motion is not in any respect connected to our PingController, let'a create a new one more descriptive.

We then create a GetEmail motion (method) which will accept a userid parameter. The [RequireHost] parameter listed here will make it accessible only to host customers, we are going to see afterwards other authentication options.

The code inside the approach alone is fairly significantly self explanatory. The only interesting factor to notice listed here is the fact that because our course inherits DnnApiController, we already have a PortalSettings item obtainable. That is the big benefit of producing use of the DotNetNuke Solutions Framework. You'll have a ModuleInfo object to represent your module (if there is 1 using the identical identify as your support, which can be not essential such on this scenario), a PortalSettings object that signifies the portal at the domain title utilized to accessibility the support (portal alias) and at last a UserInfo item symbolizing the person that accessed the web services.

Testing:

If we now navigate to http://yourdomain/MyService/API/Users/GetEmail?userid=2 you need to receive the email tackle back again from the server unless of course obviously that userid does not exist, ensure that you check having a userid that truly exists for that portal. Should you exactly where not formerly linked having a host account, you then will probably be requested for qualifications.

Limiting access to particular roles

Alright, that actually works however, you need to give host qualifications to anyone needing to make use of your webservice. To avoid which you can change [RequireHost] by [DnnAuthorize(StaticRoles="Administrators")] which can limit access to administrators. Much better however, you nevertheless must provide them with an admin account. So the easy method to give only constrained entry would be to create a brand new role in DotNetNuke only for your internet services and substitute Administrators by that specific function title within the authentication parameter.

Utilizing HttpPost : (reply to a comment down bellow)

To answer Massod comment bellow, it's nearly exactly the same thing however, you have to develop an object to contain the posted information.
Let's make a easy ping that makes use of Submit, very first we need to create an object which will contain the posted info this sort of as:

public class FormMessage
    {
        public string Message { get; set; }
    }

Then we create the service method something like this:

public class PingController : DnnApiController
   {
       [AllowAnonymous]
       [HttpPost]
       public HttpResponseMessage PostPing(FormMessage formMessage)
       {
           return Request.CreateResponse(HttpStatusCode.OK, "Pong from POST: message was '" + formMessage.Message + "'.");
       }
   }

note that normally, a post would only return ok and no message, I am just doing this so we can test here.
Now since this is a POST verb, we can't test it by only using url parameters, we need to make an html file with a form to test it out. It would be someting like this:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Pagetitle>
head>
<body>
    <form action="http://dnndev/DesktopModules/MyService/API/Ping/PostPing" method="POST">
        <label for="message">Message: label><input type="text" name="Message"/>
        <input type="submit" value="Submit"/>
    form>
body>
html>

The crucial thing to not right here is you can not just develop your Publish technique taking a string even when this can be only what you require, you do must create an object which will get your parameters.

Also never overlook that this is only for tests, you usually do not need to make this publicly accessible, you'd probably usually use yet another parameter than [AllowAnonymous] such as [DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.View)] and [ValidateAntiForgeryToken] unless you truly want that for being public.

Best Recommended DotNetNuke Hosting

ASPHostPortal.com is the leading provider of Windows hosting and affordable DotNetNuke Hosting. DotNetNuke Hosting from ASPHostPortal.com provides a safe, reliable and performance-driven foundation for your DotNetNuke website. DotNetNuke is the perfect Content Management System for managing and developing your website with one of ASPHostPortal’s Hosting plans. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.



DotNetNuke Hosting - ASPHostPortal.com :: Tips To Resolve Script Error in DNN

clock November 24, 2016 07:13 by author Armend

If you’ve made the transition from DotNetNuke 6 to DotNetNuke 7 you’ve probably discovered that the AJAX Toolkit controls don’t play nice with DotNetNuke any more.  Fortunately the Telerik AJAX controls have been bundled with DotNetNuke for version 7.  I’ve discovered that converting to the Telerik controls has been beneficial and worth the upgrade.
Still, it can be a pain getting the code right.  One particular error that I ran into today was the Registered Script Control error.  It looks something like this:

"Script control ‘{controlname}’ is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().  Parameter name: scriptControl"

The error results from “stacked” AJAX controls.  Consider the following HTML

<%@ Register TagPrefix=”dnnui” Namespace=”DotNetNuke.Web.UI.WebControls” Assembly=”DotNetNuke.Web” %>
<%@ Register TagPrefix=”DNN” Namespace=”DotNetNuke.UI.WebControls” Assembly=”DotNetNuke.WebControls” %>
   <DNN:DNNTabStrip ID=”tabsProject” runat=”server” TabRenderMode=”All” Visible=”true”>
     <DNN:DNNTab runat=”server” Label-Text=”Properties” ID=”tabGeneral”>
       <dnnui:DnnAjaxPanel runat=”server” ID=”dapMain”>
         <asp:Label runat=”server” ID=”lblInfo”></asp:Label>
       </dnnui:DnnAjaxPanel>
   </DNN:DNNTab>
     <DNN:DNNTab runat=”server” Label-Text=”Properties” ID=”tabSecond”>
       <dnnui:DnnAjaxPanel runat=”server” ID=”dapSecond”>
         <asp:Label runat=”server” ID=”lblMessage”></asp:Label>
       </dnnui:DnnAjaxPanel>
   </DNN:DNNTab>
      </DNN:DNNTabStrip>

Let’s say that the second tab (tabSecond) should only appear under certain conditions; a record was created, a particular user is logged, whatever the condition is doesn’t matter, just that the tab should appear at certain times and not appear at other times.
In the code behind the condition block might look like this:

if (condition) then
tabSecond.Visible = False
end if

But this results in the Registered Script Control error.  Modify the condition block this way:

if (condition) then
dapSecond.EnableAJAX = False
tabSecond.Visible = False
end if

This should resolve the error

What was the issue?  I’m glad you asked.
The issue causing the error is that AJAX controls are registered with the AJAX script manager and cannot be unregistered, or moved.  Hiding an AJAX control is equivalent to moving it from the script.  In order to circumvent that we’re disabling AJAX on the control before it has a chance to be rendered and registered with the script manager.

Best Recommended DotNetNuke Hosting

ASPHostPortal.com is the leading provider of Windows hosting and affordable DotNetNuke Hosting. DotNetNuke Hosting from ASPHostPortal.com provides a safe, reliable and performance-driven foundation for your DotNetNuke website. DotNetNuke is the perfect Content Management System for managing and developing your website with one of ASPHostPortal’s Hosting plans. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.



DotNetNuke Hosting - ASPHostPortal.com :: How to Create a Page Template in DotNetNuke

clock November 17, 2016 07:32 by author Armend

How to Create a Page Template in DotNetNuke

Creating page templates in DotNetNuke helps to eliminate the tiresome task of creating blank pages and adding modules one-by-one.  This DotNetNuke tutorial covers creating a model page, and saving that page as a template, allowing rapid generation of new pages.

 

I personally like to use Razor scripts to load the content of a page outside of standard HTML.  In other words, I create a template with the scripts already defined.  With all the script definitions in place, I simply create new pages from the template, and the only thing I need to add is the static HTML for that specific page.  This approach will also work with static content as well as other scripting methods. 

You need to arrange the proper DNN modules on your model page then fill in the modules with your selected content.  When you export the template, but sure to check the box to include content in your template.

The process is simple.  Once the template page is created, be sure you are logged in to the site.   Hover your mouse pointer over “Pages” in the top menu.  In the pop-up menu, select “Export “.
You will be directed to the “Export” screen where you will:

  1. Select the folder where you would like to save the template.   DNN includes a default template directory which is recommended.
  2. Type a name for the template.
  3. Type a description for the template.
  4. If you have scripts, or static content, which you will want displayed on the template pages, select the “Include Content” checkbox.

Once you save this template, you may choose to use the template when adding new DNN pages.

Best Recommended DotNetNuke Hosting

ASPHostPortal.com is the leading provider of Windows hosting and affordable DotNetNuke Hosting. DotNetNuke Hosting from ASPHostPortal.com provides a safe, reliable and performance-driven foundation for your DotNetNuke website. DotNetNuke is the perfect Content Management System for managing and developing your website with one of ASPHostPortal’s Hosting plans. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.



DotNetNuke Hosting - ASPHostPortal.com :: How to use Google Gmail SMTP in DNN website?

clock November 10, 2016 07:17 by author Armend

How to use Google Gmail SMTP in DNN website?

In this article we will explain how to use Google Gmail SMTP in DNN. If you want to use Gmail SMTP in your DNN website, this can be easily done by specifying the correct port 587 in the SMTP settings. Unfortunately, there is no port number field supplied in the SMTP settings form. So in order to include the port number, you just need to add the smtp.gmail.com:587 in the SMTP settings.
In order to set the SMTP settings, you will need to login as super host account. Note this is a super administrator account so the basic administrator account will not get the access to the host menu. Under the host settings in the advanced settings tab, you will see a section for SMTP settings. You just simply need to use the following settings. Just replace the email and password of your own.


 

Best Recommended DotNetNuke Hosting

ASPHostPortal.com is the leading provider of Windows hosting and affordable DotNetNuke Hosting. DotNetNuke Hosting from ASPHostPortal.com provides a safe, reliable and performance-driven foundation for your DotNetNuke website. DotNetNuke is the perfect Content Management System for managing and developing your website with one of ASPHostPortal’s Hosting plans. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.



DotNetNuke Hosting - ASPHostPortal.com :: Integrating Active Directory with DNN

clock October 27, 2016 07:35 by author Armend

Microsoft Active Directory (AD) is the leading identity management platform for companies. AD has powerful identity management processes that help you manage your users, groups and resources in a centralised, secure corporate directory. Active Directory integrated with DNN gives you powerful, seamless capabilities to control real-time access to your DNN site directly from Active Directory.

The standard approach for managing users in DNN is to use the native, isolated user store that is maintained within the confines of the DNN application. This is what comes out of the box. But if your employees already use AD accounts to access your company network you might want to avoid having two completely disconnected user directories.
When an employee joins, leaves or changes roles within the organization, their accounts and access to applications must be added, removed or modified. When this does not occur in a timely manner, the organization is exposed to the risk of accidental or intentional behaviors that can lead to security breaches or the disclosure of sensitive information. So you really want to control access to all your company websites with a single login  controlled by Active Directory as the single point of truth for user identity. This allows for the automatic provisioning, updating and deleting of user accounts in your DNN site whenever the user logs in, without the need for administrators to make manual changes in your DNN or Evoq  site.

Concept

Below is a simple illustration showing how DNN Platform can integrate with Active Directory. In this solution we are relying on LDAP (Lightweight Directory Access Protocol) to consume information from Active Directory.

 

  • Active Directory server provides an LDAP protocol that exposes the AD user data store.
  • DNN Platform is hosted on the IIS server that is member of the Active Directory domain.
  • Corporate users (employees) are automatically signed in to the DNN Platform.
  • Clients using Internet connection can still view DNN website as a Guest or a Registered User (if they manually sign in to the DNN).

Advantages

  • Leverage investments in the Active Directory and DNN.
  • One source of authority and group information, which is Active Directory.
  • One password for DNN and Active Directory account means reduced IT workload and increased security. Passwords are not stored in DNN.
  • Self Service Password Reset - when the Active Directory password is expiring, let your users update their own passwords.
  • Centralized audit trail – all sign-in tasks are stored in one place which is Active Directory logs, which simplifies compliance and enables cross-application analysis.
  • Approach leverages Microsoft’s Integrated Windows Authentication to authenticate users to DNN when they are logged in to their office computer. When employees are on the corporate network and signed in with their Windows credentials, they can use Desktop single signon to auto-login (from a PC or Mac) to get one-click access to their web applications. There’s no need for additional usernames or passwords, just like on-premise apps.
  • Increased security and greater peace of mind.

Implementation

All the features mentioned above can be easily implemented in your DNN by the:

  •     Paid “AD-Pro Authentication” module.
  •     Free “Auth: Active Directory” module.

“AD-Pro Authentication” is an option for customers that have more unique needs.

Corporate Users Need AD-Pro

Below are the few benefits that “AD-Pro Authentication” can provide for your users:

  • New Active Directory users can immediately sign into DNN and start work.
  • When employees or contractors leave the company, corresponding Active Directory user accounts will be disabled, “AD-Pro Authentication” will block access for those users to immediately  prevent unauthorized access and data loss.
  • Active Directory profile fields like username, email address, first name, profile picture are pushed to DNN on sign-in process. You can also easily configure which fields needs to be synced, including custom Active Directory profile fields.
  • You can specify which Active Directory groups should be imported into DNN. This is done via “Role Manager” that allows you to create a advanced mappings between AD groups and DNN roles. For example: if AD user belongs to group “Sales” assign him to DNN role “Employee and Sales”.
  • “Role Manager” allows you to define “Authorization group(s)”. Only AD users who belong to one of the “Authorization Group” will be able to login to DNN.
  • "AD-Pro Authentication" supports Integrated Windows Authentication (IWA) also known as Single Sign On (SSO).
  • "AD-Pro Authentication" allows you to configure DNN with multiple platforms and companies, that's because the module can work with multiple Active Directory domains.
  • When a Active Directory user with an expired password tries to sign into DNN, he is prompted to enter the existing password and a new password. Once that user enters a valid new password, user is signed to DNN.
  • The complexity of a new password is defined by the AD security policies where are defined attributes like: password minimum length, whether the password must contain digits or special characters, how often the password expires and how long to prevent reuse of old passwords.

Note: Active Directory user passwords are never saved in DNN. You can be sure that passwords are not stored anywhere outside the Active Directory.

Summary

Integrating your DNN site with Microsoft Active Directory helps you with:

  • Authenticating users
  • Creating and deleting user accounts
  • Storing user accounts and passwords.
  • Calling enterprise directories to look up user identity details.
  • Integrating with identity systems from other platforms or companies.

Best Recommended DotNetNuke Hosting

ASPHostPortal.com is the leading provider of Windows hosting and affordable DotNetNuke Hosting. DotNetNuke Hosting from ASPHostPortal.com provides a safe, reliable and performance-driven foundation for your DotNetNuke website. DotNetNuke is the perfect Content Management System for managing and developing your website with one of ASPHostPortal’s Hosting plans. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.



About ASPHostPortal.com

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions


Author Link


Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Tag cloud

Sign in