Monday, October 26, 2009

DNN custom logout

protected void LinkButton1_Click(object sender, EventArgs e)
{
DotNetNuke.Security.PortalSecurity.ClearRoles();

Session.Clear();

Session.Abandon();

PortalSecurity objPS = new PortalSecurity();

objPS.SignOut();
Response.Redirect("http://localhost:2887/Site/Home/tabid/39/language/en-US/Default.aspx");
}

Sunday, August 23, 2009

Set IE8 Compatibility Mode in Dot Net Nuke

Microsoft has just released Internet Explorer 8. Unfortunately, some of the pages on our website have some issues when viewed with IE8's default settings. In particular, the styling that we've done on our main page's tab control is causing issues. Users can fix these issues on the client side by selecting compatibility mode (the button to the right of the URL field shown below).






Of course, a client side fix is never a user friendly fix. Thankfully there is a meta tag that can be added to your site to force IE8 to automatically go into compatibility mode.

Our page is built in Dot Net Nuke. The appropriate way to apply this fix for DNN is to add the tag to the default.aspx file that is found in the root directory of your Dot Net Nuke website. Any meta tag that is placed in here should be applied to all pages to your website. Add the tag highlighted below in red at the top of the head section of the default.aspx file.

< id="Head" runat="server">
< equiv="X-UA-Compatible" content="IE=EmulateIE7">
< content="text/html; charset=UTF-8" equiv="Content-Type">

Note that the tag must be placed at the top of the head section. Also, be aware that updates of your DNN framework will overwrite this change.

Tuesday, August 18, 2009

Create DotNetNuke Page Description And Meta Tags Dynamically

public DotNetNuke.Framework.CDefault BasePage
{
get { return (DotNetNuke.Framework.CDefault)(Page);
}
}

protected override void OnInit(EventArgs e)
{ base.OnInit(e); BasePage.Author = "John Doe"; BasePage.Comment = "Some Comment"; BasePage.Copyright = "Some Organization"; BasePage.Description = "Some Description"; BasePage.Generator = "Some Generator";
BasePage.KeyWords = "Keyword A, Keyword B" BasePage.Title = "Some Title";
}

Monday, August 17, 2009

Check ajax installed or not in dnn at page load

if (DotNetNuke.Framework.AJAX.IsInstalled())
DotNetNuke.Framework.AJAX.RegisterScriptManager();

Wednesday, August 12, 2009

Redirec from one module to other

Step 1:

Response.Redirect(Util.RedirectUrl(this.PortalId, this.TabId, "ControlName", "ModuleName"), false);

Step 2:

public static string RedirectUrl(int PortalId, int TabId, string ControlName, string ModuleName, string Querystring)
{
string _Url = string.Empty;
ModuleInfo objModule = GetModuleByDefinition(PortalId, ModuleName);
return DotNetNuke.Common.Globals.NavigateURL(objModule.TabID, ControlName, "mid=" + objModule.ModuleID.ToString(), Querystring);
}
/////////////////////OR if using querystring

public static string RedirectUrl(int PortalId, int TabId, string ControlName, string ModuleName, string Querystring)
{
string _Url = string.Empty;
ModuleInfo objModule = GetModuleByDefinition(PortalId, ModuleName);
return DotNetNuke.Common.Globals.NavigateURL(objModule.TabID, ControlName, "mid=" + objModule.ModuleID.ToString(), Querystring);
}

Friday, July 10, 2009

How to create custom change password control

protected void btnChangePassword_Click(object sender, EventArgs e)
{
string UserName = HttpContext.Current.User.Identity.Name;
DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(PortalId, UserName);
DotNetNuke.Security.Membership.MembershipProvider membershipProvider = DotNetNuke.Security.Membership.MembershipProvider.Instance();
if (membershipProvider.PasswordFormat == DotNetNuke.Security.Membership.PasswordFormat.Encrypted)
{
string oldPassword = DotNetNuke.Entities.Users.UserController.GetPassword(ref userInfo, userInfo.Membership.PasswordAnswer);
if (oldPassword == txtOldPassword.Text)
{
string newPassword = txtNewPassword.Text.Trim();//DotNetNuke.Entities.Users.UserController.GeneratePassword(membershipProvider.MinPasswordLength);
DotNetNuke.Entities.Users.UserController.ChangePassword(userInfo, oldPassword, newPassword);
txtOldPassword.Text = "";
txtNewPassword.Text = "";
txtOldPassword.Focus();
lblmsg.Text = "Password changed successfully.";
}
else
{
lblmsg.Text = "OldPassword did not match.";
}
}
}

Thursday, February 19, 2009

DNN Optimization Steps

  1. Increase it's performance by deleting it's logs. To do that, login to your DNN site as HOST. Then go to "Admin" > "Log Viewer". Then in the log viewer page , there are "Delete selected exceptions" and "Clear log" link at the bottom of page.
  2. Another faster way would be connecting to your DNN db directly and run the following command: - delete from eventlog.
  3. Deleted blank spaces in default.aspx file.
  4. Deleted blank spaces in skin file,Javascript file.
  5. Startup performance can be increased by going to the Site Configuration settings and disable the Logging feature (by setting Logging to "0" in Site Settings or Host Settings)... obviously, this could be done if you don't need a logging feature (and I don't need it).
  6. Disable scheduler mode host>>hostsettings>>advanced settings
  7. Use the release.config from the DNN package
  8. Ensure that DNN does not run in debug mode : LI>
  9. Enable HTTP compression (http://www.dotnetjunkies.com/Article/16267D49-4C6E-4063-AB12-853761D31E66.dcik)
  10. ‘Host’ -> ‘Host Settings’ -> ‘Advanced Settings’ -> ‘Performance Settings’ -> turn on the Compression and Whitespace filter options. Don’t use this option if you have installed any SSL manager module for DNN or if you want use the internal skin, template or css editors.

  11. Set debug mode to false: .
  12. Check if the DNN caching is enabled: ‘Host’ -> ‘Host Settings’ -> ‘Advanced Settings’ -> ‘Performance Settings’ -> Select ‘Moderate Caching’ or ‘Heavy Caching’ from the ‘Performance Setting:’ drop down list.
  13. (‘Host’ -> ‘Host Settings’ -> Advanced Settings’ -> ‘Other Settings’),Select ‘Database’ for ‘Site Log Storage’,Active the ‘Disable Users Online’ checkbox.
  14. More than 50% of all DNN page content is Viewstate. To remove the Viewstate from the page content, go to: ‘Host’ -> ‘Host Settings’ -> ‘Advanced Settings’ -> ‘Performance Settings’ and select ‘Memory’ from ‘Page State Persistence:’ radio button list. This will reduce the page loading time up to 50%.
  15. Some hosting providers unload the DNN dll's after a certain time to save CPU time on their shared hosting environments. Also DNN deletes the cache after a certain time. This can be bypassed by SmarterPing by SmarterTools.SmarterPing by SmarterTools keeps DNN sites up and running and it does a great job. If you ping DNN URLs it dramatically improves the performance of DNN. Set SmarterPing to ping 4 or 5 key areas every minute. The loading times are 4 or 5 times faster.If there are any problems after you have changed this parameter and you can not go back because the update host settings button doesn’t work, perform the script below via Host -> SQL or SQL Web Admin:update hostsettings,set SettingValue = 'P',where SettingName = 'PageStatePersister'.
  16. Restrict the number of Log Types -> ‘Admin’ -> ‘Log Viewer’ -> select ‘Edit Log Configurations’ from the module menu -> delete all unimportant items.