1

I want to return error messages from a error handler I developed.

I've got this end case where URLs which contains invalid characters, are not reaching my handler, since I guess they are handled somehow earlier in the pipeline.

Example of such URL would be: http://www.example.com/MyAction<script

Is there a way to handle this special characters in webApi in an elegant way? I want to avoid developing a custom handler just for this one.

What I've tried:

  1. Implementing void Application_Error(Object Sender, EventArgs e) but no luck there, couldn't get the error on Application_EndRequest either.

  2. Tried manipulating the HttpRunTime configuration of requestPathInvalidCharacters but that didn't work.

Thanks in advance.

EDIT:

So I managed to achieve what I want by adding the requestValidationMode="2.0" to the HttpRunTime configuration.

Now my question is:

What are the downsides of doing it this way?

Y.S
  • 1,860
  • 3
  • 17
  • 30

0 Answers0