Problem with throwing own error on CmsPosting_Deleting event
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > Problem with throwing own error on CmsPosting_Deleting event




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Problem with throwing own error on CmsPosting_Deleting event  
britman@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-27-05 12:50 PM

Hi

Hoping someone can help with this.

I have the following code

public void CmsPosting_Deleting(Object sender, ChangingEventArgs e)
{
if (e.Action==PublishingAction.Delete)
{

try
{
throw new Exception("You do not have authorisation.")
}
catch (Exception ex)
{
e.Cancel = true;
e.SuppressExceptionOnCancel = true;
WebAuthorErrorEventArgs error = new
WebAuthorErrorEventArgs("FailedDelete",ex);
error.Title = "Delete Declined";
WebAuthorContext.Current.RaiseErrorEvent(error);
}
}
}

Which is basically hooking into the MCMS console delete event and
trying to throw a custom error in the Console Error control when the
user doesn't have authorisation to delete something. However when the
code runs it seems to not display the error (the code does definately
run) and returns to the parent channel of the posting that was selected
to be deleted.
If I dont set the e.SuppressExceptionOnCancel to true the standard
error displays correctly so I was hoping someone could spot where I am
going wrong???

Thanks






[ Post a follow-up to this message ]



    Re: Problem with throwing own error on CmsPosting_Deleting event  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-27-05 10:52 PM

Hi,

if SuppressExceptionOnCancel is set then the exception is consumed silently.
So you will not see the error message of your exception.

You could present this error in a label control if you like.

Cheers,
Stefan

--
This posting is provided "AS IS" with no warranties, and confers no rights

New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------


<britman@gmail.com> wrote in message
news:1122469037.464657.221530@g43g2000cwa.googlegroups.com...
> Hi
>
> Hoping someone can help with this.
>
> I have the following code
>
> public void CmsPosting_Deleting(Object sender, ChangingEventArgs e)
> {
>  if (e.Action==PublishingAction.Delete)
>  {
>
>   try
>   {
>    throw new Exception("You do not have authorisation.")
>   }
>   catch (Exception ex)
>   {
>     e.Cancel = true;
>     e.SuppressExceptionOnCancel = true;
>     WebAuthorErrorEventArgs error = new
> WebAuthorErrorEventArgs("FailedDelete",ex);
>     error.Title = "Delete Declined";
>     WebAuthorContext.Current.RaiseErrorEvent(error);
>   }
>  }
> }
>
> Which is basically hooking into the MCMS console delete event and
> trying to throw a custom error in the Console Error control when the
> user doesn't have authorisation to delete something. However when the
> code runs it seems to not display the error (the code does definately
> run) and returns to the parent channel of the posting that was selected
> to be deleted.
> If I dont set the e.SuppressExceptionOnCancel to true the standard
> error displays correctly so I was hoping someone could spot where I am
> going wrong???
>
> Thanks
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:21 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register