I have created an event receiver on the "Task" list.

If the "Due Date" is `null` then the user should be redirected to the custom error page.

Custom error page resides in the SharePoint mapped folder under "Layouts" directory.

The event receiver code is as follows:

```
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)
    {

    }
}

```

The custom error page which is of type "Application Page" having name. "DueDateErrorPage.aspx". The mark up is:

```
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
ERROR : You cannot create the task without due date
</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Custom Error Page
</asp:Content>

<asp:Content ID="PageTitleInTitleArea"     ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
Custom Error Page
</asp:Content>

```

Though in IIS, under the \_layouts direcory the page is available I am getting this output.

![enter image description here](https://i.stack.imgur.com/WxXEp.png)

How should I tackle this error? Please help.