Tuesday, March 27, 2012

DotNetNuke NavigateURL, EditURL and other path

How act NavigateURL or EditURL? What is the output in several cases?
If you want simple answers to theses questions, copy (and adapt) this code in a user control and look at the output.


  1.     <%= DotNetNuke.Common.Globals.DesktopModulePath %> - DesktopModulePath<br/>
  2.     <%= DotNetNuke.Common.Globals.LoginURL("", true) %> - LoginURL<br/>
  3.     <%= DotNetNuke.Common.Globals.NavigateURL(TabId) %> - NavigateURL<br/>
  4.     <%= DotNetNuke.Common.Globals.ResolveUrl("~/DesktopModules/NavigioMap/")%> - ResolveUrl<br/>
  5.     <%= DotNetNuke.Common.Globals.ApplicationPath%> - ApplicationPath<br/>
  6.     <%= Context.Request.Url.GetLeftPart(UriPartial.Path)%> - Context.Request.Url<br/>
  7.     <%= ApplicationAbsolutePath %> - ApplicationAbsolutePath<br/>
  8.     <%= DesktopModuleAbsolutePath %> - DesktopModuleAbsolutePath<br/>
  9.     <%= DotNetNuke.Common.Globals.NavigateURL("PoiPrint", "usid", "17") %> - NavigateURL("PoiPrint", "usid", "17")    <br/>
  10.     <%= EditUrl("usid", "17", "PoiPrint")%> - EditUrl("usid", "17", "PoiPrint")<br/>
  11.     <%= EditUrl("Settings")%> - EditUrl("Settings")<br/>




And here is the output of this code in my case when working under local IIS with a virtual folder called "navigio.website":


  1. /navigio.website/DesktopModules/ - DesktopModulePath
  2. http://localhost/navigio.website/language/en-US/Map/ctl/Login.aspx - LoginURL
  3. http://localhost/navigio.website/language/en-US/Map.aspx - NavigateURL
  4. /navigio.website/DesktopModules/NavigioMap/ - ResolveUrl
  5. /navigio.website - ApplicationPath
  6. http://localhost/Navigio.Website/Default.aspx - Context.Request.Url
  7. http://localhost - ApplicationAbsolutePath
  8. http://localhost/navigio.website/DesktopModules/ - DesktopModuleAbsolutePath
  9. http://localhost/navigio.website/language/en-US/Map/ctl/PoiPrint/usid/17.aspx - NavigateURL("PoiPrint", "usid", "17")
  10. javascript:dnnModal.show('http://localhost/navigio.website/language/en-US/Map/ctl/PoiPrint/mid/412/usid/17.aspx?popUp=true',/*showReturn*/false,550,950,true,'') - EditUrl("usid", "17", "PoiPrint")
  11. http://localhost/navigio.website/language/en-US/Map/ctl/Settings/mid/412.aspx - EditUrl("Settings")

Important notes:

  • I use friendly Url's provided by ifinity, and the sample navigio.website DotNetNuke portal is multilanguage enabled. This explains such output Url's http://localhost/navigio.website/language/en-US/Map.aspx.
  • The line 10 shows javascript:dnnModal.show(...), this is due to the Module definitions. The  "PoiPrint" Module Control is defined in a Module Definition different that the control that runs the "EditUrl(...)" code
  • The line 11 shows a standard Url as the "Settings" Module Control is defined in the same Module Definition that runs the  "EditUrl(...)" code
  • Module Definitions and other Dotnetnuke deployement stuffs are described in the DotNetNuke Wiki



Oh yes, maybe you wonder what are "ApplicationAbsolutePath" and "DesktopModuleAbsolutePath"?
They're helper properties from the base page. Here is the code:
  1.         /// <summary>
  2.         /// Gets the absolute path of the application (ie. http://localhost)
  3.         /// </summary>
  4.         public string ApplicationAbsolutePath
  5.         {
  6.             get
  7.             {
  8.                 return
  9.                     Context.Request.Url.GetLeftPart(UriPartial.Path)
  10.                                        .Substring(0,
  11.                                         Context.Request.Url.GetLeftPart(
  12.                                         UriPartial.Path).IndexOf(
  13.                                         DotNetNuke.Common.Globals.
  14.                                         ApplicationPath,
  15.                                         System.StringComparison.
  16.                                         CurrentCultureIgnoreCase));
  17.             }
  18.         }
  19.         /// <summary>
  20.         /// Gets the absolute path of the DesktopModule (ie. 
    http://localhost/navigio.website/DesktopModules/)
  21.         /// </summary>
  22.         public string DesktopModuleAbsolutePath
  23.         {
  24.             get { return String.Concat(ApplicationAbsolutePath, DotNetNuke.Common.Globals.DesktopModulePath); }
  25.         }

Thank you to http://quickhighlighter.com/ for code formatting ;-)

Thursday, July 29, 2010

Dotnetnuke roundtrip redirection

Symptom
After a deployment of Dotnetnuke, or after a change in the overall configuration (changing connection string for instance), the navigator seems redirecting infinitely until it stops with an error indicating that there are too much redirections.

Evidences
Looking with Fiddler what's happen, you get that kind of content:



<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<title id="Title"> Error </ title>
<link id="StyleSheet" href="/dnn/Install/Install.css" type="text/css"  
rel="stylesheet"> </ link>
</ head>
<body>
<form name = "Form" method = "post" action = "ErrorPage.aspx? status = 500 &
 = Thread error was + + + being aborted." id = "Form">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="blablabla" />
 
cellspacing="5" cellpadding="5" <table border="0" class="Error">
<tr>
<td> id="Image1" src="logo.gif" alt="DotNetNuke" <img border="0" /> </ td>
</ Tr>
<tr Style="height:100%;">
<td Valign="top" style="width:650px;">
<h2> DotNetNuke Error: - Version 04.08.03 </ h2>
<hr />
<p> Thread was being aborted. </ p>
</ td>
</ Tr>
<tr>
<td align="right"> <a id="hypReturn" class="WizardButton" 
href="Default.aspx"> <img border="0" /> src="/dnn/images/lt.gif" 
Return to Site </ a> </ td>
</ Tr>
<tr> <td Height="10px"> </ td> </ tr>
</ table>
</ form>
</ body>
</ html> 

Explanations
There is an Error somewhere in the Dotnetnuke startup process, therefore Dotnetnuke redirects to its error page, BUT the error page can't complete because of the Error. And so on...

Reasons
There is an error in the initialization process of Dotnetnuke. Here are some suspects:
  1. web.config with an invalid value in the connection string for instance -> no database -> error
  2. PortalAlias table has an invalid value (i.e. localhost)
  3. .Net Trust Level is not set to Full Trust, or it seems that sometime setting successively Medium then Full forces the refresh of the virtual folder config (?!? I read that somewhere, I tried, and it worked)
Conclusions
The redirection is probably not due to any redirection rule (check anyway), but is due to the fact that there is an error in the configuration and the Dotnetnuke Error page is unable to complete.
Redirection to an error page that raises an error is nightmare, check with special attention all your configurations, and you'll find the origin of the error


    Wednesday, June 16, 2010

    MVC2 table stripping

    Simple scripting tip to set an alternate class to each row of a table when rendering the HTML in an MVC2 view.

    Here, my view is a typed view and extends system.Web.Mvc.ViewPage


       1:  <table>
       2:        <thead>
       3:          <tr>
       4:            <th>
       5:              Header 1
       6:            </th>
       7:            <th>
       8:              Header 2
       9:            </th>
      10:          </tr>
      11:        </thead>
      12:        <tbody>
      13:          <% 
      14:            var rowClass = "";
      15:            foreach (var item in Model)
      16:            {
      17:              rowClass = string.IsNullOrEmpty(rowClass) 
      18:                          ? "pair" : ""; %>
      19:          <tr class="<%= Html.Encode(rowClass) %>">
      20:            <td>
      21:              <%= Html.Encode(item.Name) %>
      22:            </td>
      23:            <td>
      24:              <%= Html.Encode(item.Firstname) %>
      25:            </td>
      26:          </tr>
      27:          <% } %>
      28:        </tbody>
      29:      </table>

    14: There is a private rowClass variable defined as an empty string outside of the foreach loop
    17-18: The rowClass variable is alternatively set to "pair" or "" according to its previous value
    19: The value of rowClass is rendered as the 's class attribute values

    Of course there must be a "pair" class defined in the css.

    Thursday, September 6, 2007

    Using Visual Studio 2005 to Design Abstract Forms

    Looking on how to workaround the problem of abstract forms that are not editable through the Visual Studio Designer, I found that interresting article:

    Using Visual Studio Whidbey to Design Abstract Forms (thank you Brian)

    Here are the summarized steps to perform in order to quick-kix the issue:
    1. Download Brian's project
    2. Add the GeneralConcreteClassProvider.cs class to your project
    3. Add that class in the same namespace than you abstract form, modifying the namespace
    4. Add the following code to the head of your abstract class:

      [TypeDescriptionProvider( typeof(GeneralConcreteClassProvider))]
      [ConcreteClass(typeof(GeneralConcreteForm))]

    5. Add the definition and implementation of the GeneralConcreteForm into your abstract form, and implement the abtract ptroperties, methods...

      #region Concrete version of AbstractForm for Designer

      // Here is a concrete version of AbstractForm that acts as a stand in

      internal class GeneralConcreteForm : UIForm

      {

       public override string AbstractProperty 
      {
      get { return null; }
      set { ; }
      }

      #endregion

    6. All you'll have to maintain, is the GeneralConcreteForm with the future abstract properties and methods.
    7. That's it


    Monday, July 2, 2007