0

I have already working ASP.net Web API (.Net Framework 4.6.1) Application, And already have some "DelegatingHandler"s and "ActionFilterAttribute"s working on it to handle Authentication, and Validation filters.

I need to change Some error Messages like 404 default message :

No HTTP resource was found that matches the request URI 'https://example.com/api/someWrongUrlAction'.

So, I read about OWIN middleware, but I'm afraid of using it, and need to know will it affect any other working functionality or hosting settings? will it affect the already exists "DelegatingHandler" MessageHandlers ? or "ActionFilterAttribute" Filters?

Note: I need to use the OWIN middleware only for that purpose, but I'll keep hosting in IIS as it is.

Tarek El-Mallah
  • 4,015
  • 1
  • 31
  • 46
  • Review one of my answers along similar topic https://stackoverflow.com/a/41978109/5233410 – Nkosi Jan 29 '18 at 17:03
  • Thanks, but My question mainly if I use OWIN middleware, like in example https://stackoverflow.com/questions/24207583/uniform-consistent-error-responses-from-asp-net-web-api-2?answertab=votes#tab-top, will it affect the already exists "DelegatingHandler" MessageHandlers ? or "ActionFilterAttribute" Filters? – Tarek El-Mallah Jan 29 '18 at 17:55

1 Answers1

2

To be fair I'm not really sure why do you need an owin here. You could use either IIS tools (it will manage such routes in a best way) or you could use some of fallback approaches provided by MVC framework: MVC 6 Routing, SPA fallback + 404 Error Page or Fallback route for MVC Areas or google like 'mvc fallback route' ;-)

Regarding your question. You can host OWIN application in the IIS. You might need to switch your application to support owin pipeline. Do not think you will be able to merge both approaches inside the same application.

Igor Gnedysh
  • 144
  • 1
  • 10
  • So I understand that you recommend to use IIS approach (like "DelegatingHandler"s and "ActionFilterAttribute"s) or OWIN pipeline approach. and not mix. am I get it right? – Tarek El-Mallah Feb 05 '18 at 17:56
  • 1
    Yes, in your case it makes no sense to add an owin support into your app if you are not going to replace iis. You can handle 404 pages either on app level or iis (through iis configurations). It depends on your needs really. – Igor Gnedysh Feb 05 '18 at 21:02