I have a link that redirect users on the 'unexpected error is occured' page when they type a wrong code and submit it. If the code is valide the redirection is done and they reach the correct page.

I would like to know how to check weither the redirected page will be the 'unexpected error is occured' page or the correct one.

enter image description here

  • Can you add some sharepoint logs with correlation token "f0fac31c-..."? – Sergey B. Hizof Dec 29 '15 at 14:23
  • 1
    I don't want to fix the error because I perfectly know why it is occuring. I just don't want to reach this page. Instead, I would prefer to display a message to users. I have to say that I've already checked the html error codes. It doesn't matter which one is triggered because sharepoint will redirect to this page anyway. So I need to handle the rediection result before. – ameliapond Dec 29 '15 at 14:30

In theory there is two ways to do what you're asking:

  • Add JavaScript into the page doing the post which intercepts the post, performs it in the background and redirect the user based on the result.
  • Add a Http Module to your SharePoint farm which intercepts the redirect on the way out and the redirect you to another page (but which)

But I'd recommend that you instead try to add JavaScript to validate the user input and then not do the post if not valid. If it's a standard SharePoint Form then the validation can be done in PreSaveAction (see Marc D Andersons:Validation on SharePoint Forms – Part Four )

  • Thank you for your answer. I don't know which values are correct before I get the error page so I cannot perform a validation trick. I have no choice. I have to trying to open the page, check if it failed then display a message to user. – ameliapond Dec 29 '15 at 15:27
  • 1
    If you really don't know the valid values then the best option would be to do the get/post from JavaScript and show error message if you get error page and redirect otherwise, this requests the page twice, but ... – Per Jakobsen Dec 29 '15 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.