Last active
June 2, 2021 23:15
-
-
Save jeremy-farrance/3fd028e73a545dfbcb25005d45c398ee to your computer and use it in GitHub Desktop.
A Dnn RazorScript for when you can't get the URL redirect right with Dnn's page settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
// Where to go | |
string urlRedirect = "/tabid/21?paramname=paramvalue"; | |
if (IsAdminOrHost(Dnn.Portal.UserInfo)) | |
{ | |
<h5>You are in a site/CMS administration role, redirect is disabled for you.</h5> | |
<p>Had you been a normal user, you would have been redirected to:<br> | |
<strong>@urlRedirect</strong> | |
</p> | |
<p>This script now has a home <a href="https://gist.github.com/jeremy-farrance" target="_blank">on my Gists (GitHub)</a>. Cheers! - Jeremy</p> | |
} | |
else | |
{ | |
Response.Redirect(urlRedirect, false); | |
Context.ApplicationInstance.CompleteRequest(); | |
} | |
} | |
<p>Referrer = @Request.UrlReferrer.OriginalString</p> | |
@functions { | |
private bool IsAdminOrHost(DotNetNuke.Entities.Users.UserInfo userInfo) | |
{ | |
return userInfo.IsSuperUser || userInfo.IsInRole(DotNetNuke.Entities.Portals.PortalSettings.Current.AdministratorRoleName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On a new, normal page, add a Razor Host module, new script, set a useful (to you) filename, copy the code (above) in, change the
urlRedirect
to what you want, save, make sure its active. As long as you are an Admin or Super, the redirect doesn't fire and reminds you of what is going on.