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 Compile DNN Module Using Visual Studio Starter Kit

clock February 23, 2017 04:50 by author Armend

The Visual Studio Starter Kit enables you to create a compiled DotNetNuke module that can be much more compact, more quickly, and hide your supply code from prying eyes. The subsequent instructions can get you started and well in your approach to creating compiled DotNetNuke Modules.

  1. Download the Starter Kit
  2. Open Visual Studio  and create a new project (File -> New Project)

  1. From the dialogue follow these steps

    • Select Web from the Installed Templates. I use of VB.Net, but they are available in C# too.
    • Pick DotNetNuke Compile Module from your Project Type list.
    • Enter your Module Name
    • Enter the path for your DotNetNuke installation. Your project will be installed within the current set up within the DesktopModules folder and also the dll will likely be place in the bin folder.
    • Click OK
  2. Visual Studio will load up the venture within the Solution Explorer and open the Documentation.html in the editor. You’re not however ready to set up the module so don’t keep to the DotNetNuke documentation but.
  3. In the Solution Explorer right click on My Project and select Open.

Within the Application tab delete the entry in Root Namespace except if this is your only module, otherwise you will not be sharing code with other modules. I have a undertaking that spans numerous modules and i want them all inside the identical identify space. So, I delete the basis Namespace entry to ensure that I am able to put within the appropriate namespace from the code driving. (Edit regarding Root Namespace; in C# you do not need to clear the namespace, but in VB.Net you are doing).

  1. Switch towards the Compile tab. Verify the Build output path and make sure its pointing towards the proper bin folder. Now simply click the Advance Compile Option on the button of the tab. Around the dialogue make certain the target framework is correct. You’ll see the environment on the base of the dialogue. At this point the dialogue will immediately near.
  2. Repeat step 4 (open the project properties) then go to step 8
  3. Switch to the References tab.  You should see a reference to DotNetNuke.Library version 0.0.0.0.  Remove it

Nonetheless around the References tab, now click the Add button. Inside the Add Reference dialogue switch to the Browse tab and navigate for the DotNetNuke set up bin folder. Choose the DotNetNuke.dll, DotNetNuke.Web.dll, as well as the Telerik.Web.UI.dll. Should you do not hold the Telerik.Web.UI.dll then you definitely should not be making use of those controls and you also will not want the dll. Click Okay. These references are necessary to obtain access to the DotNetNuke methods and properties. In any other case you are code powering will be crammed with inexperienced and blue underlines, missing references, and, oh yeah, it won’t compile. Sort of defeats the aim, proper?

  1. Intellisense; this step is optional, but if you want Intellisense you’ll want to do this.  Switch to the Web tab. Under Servers select the “Use Local IIS Web server” option.  Change the Project URL to the full URL of your project (eg http://{domain}/DesktopModules/{project folder}).  Check “Override application root URL” and set it to the domain of your DotNetNuke install (eg http://{domain})
  2. Save the Project Properties and close it.
  3. Inside the Solution Explorer increase the Components folder and open up the ModuleNameController.vb (or .cs) file. Check the Namespace declaration and you’ll see that it states “YourCompany”. Change this to your customized namespace identifier and after that do the identical in each of the code powering documents. You will also need to change it inside the .ascx files because they’ll be reference the namespace inside the handle declaration at the best of the webpage.
  4. At this point you can Build your project and you will see the new dll in your DotNetNuke install bin folder.
  5. Now follow the instructions in the documentation.html to install the module in DotNetNuke.  Once the module is installed you don’t really need the documentation folder, or it’s files.  I usually delete it.

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 :: How To Manage Pages in DNN

clock February 16, 2017 05:05 by author Armend

To create a new page in DNN is pretty simple. After you login on the site, look for the menu Pages and hover your mouse into the menu, a sub menu will appear under the menu. Click the option Add New Page.

A pop up window will appear like below.

Page Properties in DNN

Below is the main properties that you will basically utilize in daily use.

  • Page Name : Page name must unique and can not be duplicate or has the same name with other pages. What ever you type in here, it will appear exactly in the site menu.
  • Page Title : Page Title is used for meta tag Title. You can optimize your site by specifying individual unique title for each page.
  • Page URL : You can define your own custom url in here. This will help optimize your site for SEO purposes.
  • Description : This will be used in meta tag description. You can include a brief description about this page.
  • Keywords : This will be used in meta tag keyword. You can separate a keyword by comma. Note: most search engine will no longer consider the meta keyword as important factor for search engine search.
  • Include in Menu : By untick this one, the menu will be hidden and will not be visible in the site menu.

Manage Page's Permission

Each page has its own permission. If you see below picture,


The page permission will list available roles in the current site portal. By default Administrators, All Users, Registered Users, Subscribers, Translators, Unauthenticated Users, and Unverified Users are predefined in DNN. What we interest most are probably All Users which cover all user roles, Registered Users which cover registered members only and Administrators which covers admin account only. If you want to make the site visible to all users then you should tick All Users View Option. The Edit option, give ability to specific role to edit the content of the page. The content in here are the modules of the page, it could be HTML modules, news modules etc. If you do not want any public users able to view this page, you can set to Registered Users. But if you want to give the page visibility to admin only, then you should choose Administrators.


Alternatively, you can use Page Managements to manage your site pages easily. This menu is available under the Site menu. Please see below screenshot.

 

All your pages will be displayed in a tree menu on the left hand side. To edit the page, you can just click the menu name. If you want to delete the page, you can just simple right click the menu link.

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 :: Writing a New Authentication in DotNetnuke

clock February 2, 2017 05:00 by author Armend

My companion organization already had ADFS setup. My purpose was to have the partner organization authenticate the user after which have DNN automatically recognize the user, not obtaining to enter any far more credentials. From there we wanted to manage the groups and permissions by way of the standard DNN portal.
I was initially beneath the misconception that I couldn't make use of the present DNNMembershipProvider and I'd have to generate a whole new Authentication Provider and gather the credentials and pass them to my partner organization.

What I have figured out is that you can use the existing DNNMembership provider, but you've got to make the user ahead of the request gets towards the DNNMembership provider making use of the info offered by ADFS.

Note: This approach is really a straight pass-through from ADFS to DNN. No measures are taken to authenticate the user or to check any from the inputs from ADFS.

As an aside, this method performs not just with ADFS but in addition any other external 3rd-party Authentication approach that sends user info in headers or cookies. Change the context_AuthenticateRequest approach to suit your requirements.

Right here are the pre-conditions to this article. I expect:

  • Your partner organization has ADFS up and running
  • You have your ADFS proxy up and running and it talks to the partner organization.
  • ADFS Web Agent is installed on the server you are running.

Let’s get begin.

HTTPModule

What you've to complete is produce an HTTPModule that will intercept the AuthorizeRequest events ahead of DNN does. An over-simplified definition of an HTTPModule is, it is a piece of code that runs ahead of any web page gets hit. You can listen for a large amount of distinct events. For much more data, click right here.

To make the HTTPModule you'll need to:

  • Open Visual Studio and produce a brand new class library.
  • Generate a brand new class and copy the code attached to this blog.
  • Add References to the following DLLs
    • DotNetNuke
    • System.Web
    • System.Web.Security.SingleSignOn
    • System.Web.Security.SingleSignOn.ClaimsTransform
    • System.Web.Security.SingleSignOn.Permissions
  • Compile the solution
  • The DLL that is created will need to be placed in the bin directory of your website.
  • Make changes to your web.config (explained in a later section).

I will walk through a bit of the code. Here is the first snippet of code. We start listening for the AuthenticateRequest event. All other events pass through untouched.

public void Init(HttpApplication context)
{
//Start listening for each authentication request
context.AuthenticateRequest += new EventHandler(context_AuthenticateRequest);
}

Now, what do we do when this event is fired off? To shorten the namespace I added the statement

using SSO = System.Web.Security.SingleSignOn;

First off, we need to get the information that ADFS has sent us by casting the User.Identity into the ADFS object SingleSignOnIdentity.

public void context_AuthenticateRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
//By the time the request gets to here, it should have been authenticated
//against ADFS.
SSO.SingleSignOnIdentity id = (SSO.SingleSignOnIdentity)app.User.Identity;

At this point you will have access to the user’s Identity and any claims coming from the ADFS server. You can access them through id.SecurityPropertyCollection. You can use them to populate the new user account. You can iterate through the claims with the following code

foreach(SecurityProperty sp in id.SecurityPropertyCollection)
{
    Console.WriteLine(sp.Name);
    Console.WriteLine(sp.Value);
}

Subsequent, we check to determine in the event the use currently exists within the database by utilizing the DNN API function GetUserByName. If it doesn’t, then the user is created by the common DNN API function CreateUser and logged in. If the user does exist currently then we log them in automatically. The user will automatically be added to the Registered Users and Subscribers security groups.

//'See if user exists in DNN Portal user DB
UserInfo objUserInfo = UserController.GetUserByName(currentPortal.PortalId, id.Name);
//' user does exist - try to create on the fly
if (objUserInfo == null)
{
    objUserInfo = new UserInfo();
    objUserInfo.DisplayName = id.Name;
    objUserInfo.FirstName = id.Name;
    objUserInfo.LastName = id.Name;
    objUserInfo.Username = id.Name;
    objUserInfo.Membership.Password = "AReallyStrongPassword";
    objUserInfo.PortalID = currentPortal.PortalId;
    objUserInfo.Email = id.Name;
    UserCreateStatus objUserCreateStatus = UserController.CreateUser(ref objUserInfo);
    //See if the user was added successfully
    if (objUserCreateStatus == UserCreateStatus.Success)
    {
        //We have created them successfully, so let them into the site
        LetsLogUserIn(objUserInfo);
    }
    else
    {
        //This will send the error to the error log, but the user will experience an infinite loop
        throw new Exception("User not created successfully: " + objUserInfo.Username + "- " +         objUserCreateStatus.ToString());
}

Here is the LetsLogUserIn function:

private void LetsLogUserIn(UserInfo objUserInfo)
{
    try
    {
    //Get the current portal
    PortalSettings currentPortal = PortalController.GetCurrentPortalSettings();
    //set the language to the default language of the portal
    Localization.SetLanguage(currentPortal.DefaultLanguage);
    //Log the user in
        UserController.UserLogin(currentPortal.PortalId,
            objUserInfo,
            currentPortal.PortalName,
            HttpContext.Current.Request.UserHostAddress,
            false);
    }
    catch(Exception ex)
    {
        Exceptions.LogException(ex);
    }
}

Web.Config

We need to make several changes to the web.config. First we need to make the changes necessary for ADFS and then we need to make changes for our HTTPModule.

The ADFS changes are the standard web.config changes you would do for any ADFS claims-aware site. You first need to add the section groups to your web.config.

<sectionGroup name="system.web">
    <section name="websso" type="System.Web.Security.SingleSignOn.WebSsoConfigurationHandler,                                  System.Web.Security.SingleSignOn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" />
</sectionGroup>

Then you need to add the actual section. The <returnurl> needs to be EXACTLY what is put into ADFS. Remember, this URL needs to have a / at the end to prevent ADFS from posting to a directory listing. The <fs> element needs to be changed to reflect the name of your server.

<system.web>

    <websso>
        <authenticationrequired />
        <auditlevel>55</auditlevel>
        <urls>
            <returnurl>https://your_application/</returnurl>
        </urls>
        <fs>https://fs-server/adfs/fs/federationserverservice.asmx</fs>
    </websso>

</system.web>

If you would like to have logging (and who doesn’t like loggingJ) you will need to add the following section at the end of your web.config

<configuration>

<system.diagnostics>
     <switches>
       <!-- enables full debug logging -->
       <add name="WebSsoDebugLevel" value="255" />
     </switches>
     <trace autoflush="true" indentsize="3">
       <listeners>
         <!-- either create a c:\logs directory and grant Network Service permission to write to it, or remove this listener -->
         <add name="MyListener"
              type="System.Web.Security.SingleSignOn.BoundedSizeLogFileTraceListener, System.Web.Security.SingleSignOn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null"
              initializeData="c:\logs\webagent.log" />
       </listeners>
     </trace>
   </system.diagnostics>
</configuration>

Ultimately, you need to add the HTTPModules for ADFS and our HTTPModule. Order matters a good deal for the HTTPModules. We require the ADFS Web Agent to become listed first, to ensure that any request will likely be redirected to our partner’s logon screen. Right away following the Web Agent should be our HTTPModule. This will make sure that we'll automatically log them on just before DNN even see it.

<system.web>
<httpModules>
    <add name="Identity Federation Services Application Authentication Module"                       type="System.Web.Security.SingleSignOn.WebSsoAuthenticationModule, System.Web.Security.SingleSignOn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null" />
 
    <add name="HTTP_Module_Test" type="HTTP_Module_Test.SSO_Module, HTTP_Module_Test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>

There you have it Hope it helps someone.

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.

Save



DotNetNuke Hosting - ASPHostPortal.com :: How To Restore Database Scema on DNN

clock January 26, 2017 04:54 by author Armend

Dotnetnuke standard installs using the dbo as the default user. Some hosts however, like shared hosting service providers, do not allow you to use dbo. So in this case you have to install Dotnetnuke using your assigned username. This should work without any problems. But in case you have an existing website which was installed using the dbo user and you would like to migrate it to a hosting provider that does not allow dbo you have a problem.

The easiest way to migrate a Dotnetnuke website is by backing up the entire web and the database and restore it to the new environment. This will work fine only if your new environment allows dbo. If it does not you will find that when restoring the database all objects will have been assigned to your username and not to dbo and your web will not run.

To resolve this issue you can follow the steps outlined below after which your web will run without any problems. As this procedure requires changes to the databse please be sure to have a backup of your database and website. Note: This procedure is for a SQL server 2005 database!

Step 1:
Open your web.config file and look for "owner". Change the owner from dbo to your database username.
Open your web.config file and look for "owner". Change the owner from dbo to your database username.

Step 2:
In Microsoft SQL Server management studio select all stored procedures that DO NOT have aspnet in their name, rightclick and select "script as create to new query editor window".
In Microsoft SQL Server management studio select all stored procedures that DO NOT have aspnet in their name, rightclick and select "script as create to new query editor window".

This will create a script for all the selected stored procedures.

Step 3:
Where it says "new owner" below you should change it for your database username!
Where it says "new owner" below you should change it for your database username!

  • In the just created script search and replace "create procedure" with "alter procedure"
  • Search and replace "create procedure" with "alter procedure" (Note! with 2 spaces!)
  • Search and replace "[dbo]" with "[new owner]"
  • Search and replace "dbo." with "new owner."
  • Execute the script

Step 4:
In Microsoft SQL Server management studio select all stored views that DO NOT have aspnet in their name, rightclick and select "script as create to new query editor window".
In Microsoft SQL Server management studio select all stored views that DO NOT have aspnet in their name, rightclick and select "script as create to new query editor window".

Step 5:

  • Search and replace "[dbo]" with "[new owner]"
  • Search and replace "dbo." with "new owner."
  • Search and replace "create view" with "alter view"
  • Search and replace "new owner.GetListParentKey" width "dbo.GetListParentKey"
  • Execute the script

Step 6:

  • Go to "functions" "Scalar-valued functions"
  • rightclick and select "script as create to new query editor window" for function "fn_GetVersion"
  • Search and replace "dbo." with "new owner." (including the "."!)
  • Execute script

Step 7:

Open a new query window and paste the following script:

ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Applications
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Profile
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Roles
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_SchemaVersions
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Users
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_UsersInRoles
ALTER SCHEMA dbo TRANSFER [USERNAME].vw_aspnet_Applications
ALTER SCHEMA dbo TRANSFER [USERNAME].vw_aspnet_MembershipUsers
ALTER SCHEMA dbo TRANSFER [USERNAME].vw_aspnet_Profiles
ALTER SCHEMA dbo TRANSFER [USERNAME].vw_aspnet_Roles
ALTER SCHEMA dbo TRANSFER [USERNAME].vw_aspnet_Users
ALTER SCHEMA dbo TRANSFER [USERNAME].vw_aspnet_UsersInRoles
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Applications_CreateApplication
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_UnRegisterSchemaVersion
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_CheckSchemaVersion
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Users_CreateUser
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Users_DeleteUser
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_AnyDataInTables
ALTER SCHEMA dbo TRANSFER
[USERNAME].aspnet_Membership_CreateUser
ALTER SCHEMA dbo TRANSFER
[USERNAME].aspnet_Membership_GetUserByName
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_GetUserByUserId

ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_GetUserByEmail
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_GetPasswordWithFormat

ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_UpdateUserInfo
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_GetPassword
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_SetPassword
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_ResetPassword
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_UnlockUser
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_UpdateUser
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_ChangePasswordQuestionAndAnswer

ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_GetAllUsers
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_GetNumberOfUsersOnline

ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_FindUsersByName
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Membership_FindUsersByEmail
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Profile_GetProperties
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Profile_SetProperties
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Profile_DeleteProfiles
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Profile_DeleteInactiveProfiles
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Profile_GetNumberOfInactiveProfiles

ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Profile_GetProfiles
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_UsersInRoles_IsUserInRole
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_UsersInRoles_GetRolesForUser
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Roles_CreateRole
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Roles_DeleteRole
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Roles_RoleExists
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_UsersInRoles_AddUsersToRoles

ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_UsersInRoles_RemoveUsersFromRolesALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_UsersInRoles_GetUsersInRoles
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_UsersInRoles_FindUsersInRole
ALTER SCHEMA dbo TRANSFER [USERNAME].aspnet_Roles_GetAllRoles
Grant execute on aspnet_Setup_RestorePermissions to [USERNAME]
Grant execute on aspnet_Setup_RemoveAllRoleMembers to [USERNAME]
Grant execute on aspnet_RegisterSchemaVersion to [USERNAME]
Grant execute on aspnet_Applications_CreateApplication to [USERNAME]
Grant execute on aspnet_UnRegisterSchemaVersion to [USERNAME]
Grant execute on aspnet_Users_CreateUser to [USERNAME]
Grant execute on aspnet_Users_DeleteUser to [USERNAME]
Grant execute on aspnet_AnyDataInTables to [USERNAME]
Grant execute on aspnet_Membership_CreateUser to [USERNAME]
Grant execute on aspnet_Membership_GetUserByName to [USERNAME]
Grant execute on aspnet_Membership_GetUserByUserId to [USERNAME]
Grant execute on aspnet_Membership_GetUserByEmail to [USERNAME]
Grant execute on aspnet_Membership_GetPasswordWithFormat to [USERNAME]
Grant execute on aspnet_Membership_UpdateUserInfo to [USERNAME]
Grant execute on aspnet_Membership_GetPassword to [USERNAME]
Grant execute on aspnet_Membership_SetPassword to [USERNAME]
Grant execute on aspnet_Membership_ResetPassword to [USERNAME]
Grant execute on aspnet_Membership_UnlockUser to [USERNAME]
Grant execute on aspnet_Membership_UpdateUser to [USERNAME]
Grant execute on aspnet_Membership_ChangePasswordQuestionAndAnswer to [USERNAME]

Grant execute on aspnet_Membership_GetAllUsers to [USERNAME]
Grant execute on aspnet_Membership_GetNumberOfUsersOnline to [USERNAME]
Grant execute on aspnet_Membership_FindUsersByName to [USERNAME]
Grant execute on aspnet_Membership_FindUsersByEmail to [USERNAME]
Grant execute on aspnet_Profile_GetProperties to [USERNAME]
Grant execute on aspnet_Profile_SetProperties to [USERNAME]
Grant execute on aspnet_Profile_DeleteProfiles to [USERNAME]
Grant execute on aspnet_Profile_DeleteInactiveProfiles to [USERNAME]
Grant execute on aspnet_Profile_GetNumberOfInactiveProfiles to [USERNAME]
Grant execute on aspnet_Profile_GetProfiles to [USERNAME]
Grant execute on aspnet_UsersInRoles_IsUserInRole to [USERNAME]
Grant execute on aspnet_UsersInRoles_GetRolesForUser to [USERNAME]
Grant execute on aspnet_Roles_CreateRole to [USERNAME]
Grant execute on aspnet_Roles_DeleteRole to [USERNAME]
Grant execute on aspnet_Roles_RoleExists to [USERNAME]
Grant execute on aspnet_UsersInRoles_AddUsersToRoles to [USERNAME]
Grant execute on aspnet_UsersInRoles_RemoveUsersFromRoles to [USERNAME]
Grant execute on aspnet_UsersInRoles_GetUsersInRoles to [USERNAME]
Grant execute on aspnet_UsersInRoles_FindUsersInRole to [USERNAME]
Grant execute on aspnet_Roles_GetAllRoles to [USERNAME]
Grant execute on aspnet_CheckSchemaVersion to [USERNAME]
Grant execute on GetListParentKey to [USERNAME]

Search and replace [USERNAME] for your database username and execute the script.

Step 8:
Refresh your database manager window and you should now see that all AspNet tables and storedprocedures belong to the dbo user/schema. Open your website in your browser. Your website should now load as normal.

Best Recommended DotNetNuke Hosting

ASPHostPortal.com

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 :: Easy Tips DNN Installation Process

clock January 19, 2017 04:45 by author Armend

In this article I would like to explains you step by step process to installation DotnetNuke.

Step by step process to installation DotnetNuke

  • Unzip the DNN file.
  • Rename
  • Make Two Folders in side UnZip folder
    • SQLExpress_DBFile
    • Website
  • Move all files inside the Website Folder except SqlExpressFolder.
    • Modify WebConfig.
  • Host it to IIS
    • Open IIS
    • Add new website (exp: DNNDEV.ME)
      • Site name :DNNDEV.ME
      • Provide physical path of dnn(Mark it to website folder under dnn folder)
      • Host name:DNNDEV.ME(same as site name)
  • After adding site you have to provide it permission:
    • Right click website folder > Edit permission > Security
    • Under Security click Edit > ADD > iis apppool\DC700X_DEV5 (your site name)
    • Allow it to All permission
  • Now add it to Host sites
    • Open notepad as Administration > File > Open > Brows (C > Windows32 > Systems > Drivers > host(Select all files) remove Read only permission
    • Now open Host and add 127.0.0.1 DNNDEV.ME (as per your ip and site name)
    • Now save and give it Read only Permission.

Make Data Base for dnn

  • Open SqlServer > Database(right click) >Add new DB > Paste here DNNDEV.ME(original site or host name as in IIS)
  • Open Database > Security > Logins (Create new user)
    • Login Name :DNNDEV.ME
    • Check Sql Server Authentication (nt Windows Auth)
    • Pas :Database,Confirm pass:Database
    • Make Enforce Password Policy Uncheck Then cilck > OK
  • Open DNNDEV.ME > Security > USers (right click) > New USer
    • User Name :DNNDEV.ME
    • Default Scheme : dbo
    • Select both chk to db_owner then click ok

Run DNN from IIS

  • Fill all field as per your back entrys.
  • Change Custom.

Now its running
Template Modify Process

Best Recommended DotNetNuke Hosting

ASPHostPortal.com

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 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 :: 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.



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