title: Unable to redirect from sharepoint event receiver
body: <p>I have created an event receiver on the "Task" list.</p>
  
  <p>If the "Due Date" is <code>null</code> then the user should be redirected to the custom error page.</p>
  
  <p>Custom error page resides in the SharePoint mapped folder under "Layouts" directory.</p>
  
  <p>The event receiver code is as follows:</p>
  
  <pre><code>public override void ItemAdding(SPItemEventProperties properties)
  {
      try
      {
          if (properties.AfterProperties["Due Date"] == null)
          {
              properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
              properties.RedirectUrl = "_layouts/CustomErrorPage/DueDateErrorPage.aspx";
          }
      }
      catch (Exception ex)
      {
  
      }
  }
  </code></pre>
  
  <p>The custom error page which is of type "Application Page" having name. "DueDateErrorPage.aspx". The mark up is:</p>
  
  <pre><code>&lt;asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server"&gt;
  
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"&gt;
  ERROR : You cannot create the task without due date
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server"&gt;
  Custom Error Page
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="PageTitleInTitleArea"     ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" &gt;
  Custom Error Page
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>Though in IIS, under the _layouts direcory the page is available I am getting this output.</p>
  
  <p><img src="https://i.stack.imgur.com/WxXEp.png" alt="enter image description here"></p>
  
  <p>How should I tackle this error? Please help.</p>