Server exception in ContentManager publish content begin/end date picker

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
11/18/2010 4:22:58 PM
Gravatar
Total Posts 3

Server exception in ContentManager publish content begin/end date picker

Hello,

I'm a computer science student evaluating mojoPortal as part of my coursework. I found a few issues which I believe are bugs and I will list them in this post. I've been able to set up the source code on my workstation and was able to debug the issues. I have created a code patch to fix the issues and I will email you the patch file for your consideration.

But first details about my environment:

What operating system? Windows XP SP2

What database platform? MS SQL 2008

What version of mojoPortal? 2.3.5.6 MSSQL

Steps to produce the problem

1. Make sure you have some content and pages created in your site. Go to Administration > Content Manager. Click on Publish/Delete...

2. On any content row, click on the Publish button and notice the row becomes editable with inline pickers for start date and end date. Also notice that the start date picker is pre-populated with today's date.

3. Clear the date and click update. A server side exception "String was not recognized as a Valid DateTime." is thrown.

4. Instead of clearing out the start date, enter invalid dates such as character strings into the start date/ end date picker and click update. A server side exception "String was not recognized as a Valid DateTime. There is an unknown word starting at index 0." is thrown.

Expected results:  In both cases, the expectation is that validation error messages should display next to date fields, indicating "Start Date is required" and "Invalid date" accordingly. The end user should not be exposed to detailed system generated run time exception messages.

Thanks

Van

 

11/18/2010 4:26:44 PM
Gravatar
Total Posts 3

Re: Code patch offered to fix server exception

diff --git a/Web/Admin/ContentManager.aspx b/Web/Admin/ContentManager.aspx
--- a/Web/Admin/ContentManager.aspx
+++ b/Web/Admin/ContentManager.aspx
@@ -70,7 +70,8 @@
                 <%# GetDisplayBeginDate(Eval("PublishBeginDate"))%>
             </ItemTemplate>
             <EditItemTemplate>
-                <mp:DatePickerControl id="dpBeginDate" runat="server" Text='<%# GetBeginDate(Eval("PublishBeginDate")) %>' ShowTime="True"></mp:DatePickerControl>
+                <mp:DatePickerControl id="dpBeginDate" runat="server" Text='<%# GetBeginDate(Eval("PublishBeginDate")) %>' ShowTime="True"></mp:DatePickerControl><br />
+                <asp:RequiredFieldValidator ID="reqElement" runat="server"  ControlToValidate="dpBeginDate"  ErrorMessage='<%# Resources.Resource.ContentPublishBeginDateRequiredMessage %>' Display="Dynamic" />
             </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="">
diff --git a/Web/Admin/ContentManager.aspx.cs b/Web/Admin/ContentManager.aspx.cs
--- a/Web/Admin/ContentManager.aspx.cs
+++ b/Web/Admin/ContentManager.aspx.cs
@@ -160,6 +160,24 @@
 
             DateTime beginDate;
             DateTime endDate;
+            Boolean beginDateInvalid = false;
+           
+            if (!DateTime.TryParse(dpBegin.Text, out beginDate))
+            {
+                beginDateInvalid = true;
+            }
+
+            if (dpEnd.Text.Length > 0)
+            {
+                if (!DateTime.TryParse(dpEnd.Text, out endDate))
+                {
+                    endDate = DateTime.MinValue;
+                }
+            }
+            else
+            {
+                endDate = DateTime.MinValue;
+            }
 
             if (timeZone != null)
             {
@@ -163,8 +181,8 @@
 
             if (timeZone != null)
             {
-                beginDate = DateTime.Parse(dpBegin.Text).ToUtc(timeZone);
-                endDate = dpEnd.Text.Length > 0 ? DateTime.Parse(dpEnd.Text).ToUtc(timeZone) : DateTime.MinValue;
+                beginDate = beginDateInvalid ? DateTime.UtcNow.ToLocalTime(timeZone) : beginDate.ToUtc(timeZone);
+                if (endDate != DateTime.MinValue) endDate = endDate.ToUtc(timeZone);
             }
             else
             {
@@ -168,6 +186,6 @@
             }
             else
             {
-                beginDate = DateTime.Parse(dpBegin.Text).AddHours(-timeOffset);
-                endDate = dpEnd.Text.Length > 0 ? DateTime.Parse(dpEnd.Text).AddHours(-timeOffset) : DateTime.MinValue;
+                beginDate = beginDateInvalid ? DateTime.Now.AddHours(-timeOffset) : beginDate.AddHours(-timeOffset);
+                if (endDate != DateTime.MinValue) endDate = endDate.AddHours(-timeOffset);
             }
@@ -173,7 +191,4 @@
             }
-           
-
-           
 
             PageSettings currentPage = new PageSettings(siteSettings.SiteId, pageID);
             currentModule = new Module(moduleID);
diff --git a/Web/Admin/ContentManager.aspx.designer.cs b/Web/Admin/ContentManager.aspx.designer.cs
--- a/Web/Admin/ContentManager.aspx.designer.cs
+++ b/Web/Admin/ContentManager.aspx.designer.cs
@@ -1,6 +1,5 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.4927
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
@@ -5,6 +4,6 @@
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
+//     the code is regenerated.
 // </auto-generated>
 //------------------------------------------------------------------------------
 
diff --git a/Web/App_GlobalResources/Resource.Designer.cs b/Web/App_GlobalResources/Resource.Designer.cs
--- a/Web/App_GlobalResources/Resource.Designer.cs
+++ b/Web/App_GlobalResources/Resource.Designer.cs
@@ -2158,6 +2158,15 @@
         }
        
         /// <summary>
+        ///   Looks up a localized string similar to Begin date is required..
+        /// </summary>
+        internal static string ContentPublishBeginDateRequiredMessage {
+            get {
+                return ResourceManager.GetString("ContentPublishBeginDateRequiredMessage", resourceCulture);
+            }
+        }
+       
+        /// <summary>
         ///   Looks up a localized string similar to Content Status.
         /// </summary>
         internal static string ContentStatusLabel {
diff --git a/Web/App_GlobalResources/Resource.resx b/Web/App_GlobalResources/Resource.resx
--- a/Web/App_GlobalResources/Resource.resx
+++ b/Web/App_GlobalResources/Resource.resx
@@ -5172,4 +5172,7 @@
   <data name="NewsletterViewAsWebPageLink" xml:space="preserve">
     <value>View as Web Page</value>
   </data>
+  <data name="ContentPublishBeginDateRequiredMessage" xml:space="preserve">
+    <value>Begin date is required.</value>
+  </data>
 </root>
\ No newline at end of file
diff --git a/Web/EditAccessDenied.aspx b/Web/EditAccessDenied.aspx
--- a/Web/EditAccessDenied.aspx
+++ b/Web/EditAccessDenied.aspx
@@ -4,10 +4,8 @@
 <asp:Content ContentPlaceHolderID="leftContent" ID="MPLeftPane" runat="server" />
 <asp:Content ContentPlaceHolderID="mainContent" ID="MPContent" runat="server">
     <div class="accessdenied">
-        <h2>
-            <mp:SiteLabel ID="lblEditAccessDeniedLabel" runat="server" ConfigKey="EditAccessDeniedLabel"
-                CssClass="txterror" UseLabelTag="false"></mp:SiteLabel>
-        </h2>
+        <mp:SiteLabel ID="lblEditAccessDeniedLabel" runat="server" ConfigKey="EditAccessDeniedLabel"
+            CssClass="txterror" UseLabelTag="false"></mp:SiteLabel>
         <p>
             <asp:HyperLink ID="lnkHome" runat="server" />
         </p>
diff --git a/Web/EditAccessDenied.aspx.designer.cs b/Web/EditAccessDenied.aspx.designer.cs
--- a/Web/EditAccessDenied.aspx.designer.cs
+++ b/Web/EditAccessDenied.aspx.designer.cs
@@ -1,6 +1,5 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.3053
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
@@ -5,6 +4,6 @@
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
+//     the code is regenerated.
 // </auto-generated>
 //------------------------------------------------------------------------------
 
 

11/19/2010 7:16:35 AM
Gravatar
Total Posts 18439

Re: Server exception in ContentManager publish content begin/end date picker

Hi Van,

Thanks for your bug report and patch! I have applied your changes and committed it to our source code repository.

The end user should not be exposed to detailed system generated run time exception messages.

In  a production installation the user would not be shown any error detail, only a generic error page would be shown. By default error detail is only shown when running in the context of localhost, this is good in order to help developers understand an error, but it would not happen in production environments. Note that whether error detail is shown or not is controlled by a Web.config setting:

<-- "On" Always display custom (friendly) messages.
               "Off" Always display detailed ASP.NET error information.
               "RemoteOnly" Display custom (friendly) messages only to users not running on the local
Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients. -->

<customErrors mode="RemoteOnly" defaultRedirect="Error.htm">
<error statusCode="413" redirect="~/NeatUpload/Error413.aspx" />
</customErrors> 

Thanks again!

Joe

 

12/1/2010 8:12:06 AM
Gravatar
Total Posts 3

Re: Server exception in ContentManager publish content begin/end date picker

Joe,

Thank you for accepting the bug report and patch. It is good to know about the web config setting for error handling. I look forward to contributing more to mojoportal in future.

Van

You must sign in to post in the forums. This thread is closed to new posts.