Selfhosting doesn't support asxh handlers?

Answered
0
0

Hi,

Am I right in saying that when running a wisej app. with selfhosting, ashx handlers are not supported?

I’ve just tried it and my handler isn’t working when self-hosted. Works fine in IIS.

Any way around this?

Thanks

Darren

  • You must to post comments
Best Answer
0
0

Thank you for sample. It works fine here, but I see what the problem is:

localhost:8080/Handler1.ashx?name=Test

The handler is found and executed correctly.

You get 404 probably because you are not using the handler but the url mapping in web.config, which is a non-existing url mapped to the handler.

localhost:8080/post-data?name=Test returns 404 with the self hosted executable.

You can fix this in WisejMiddleware.cs, see method ProcessSubApplication(IOwinContext context), the last line is:

return this.Next.Invoke(context);

Change it to:

return ProcessAspNetRequest(context);

The mapping doesn’t have an extension so Wisej Middleware tries to execute a sub application. Change that line and the mapping will work. Or you can address the handler directly as shown above.

 

  • Darren
    Hi Luca, I use Visual Studio 2012 Pro at work, which is evidently too old to re-compile your Wisej.HostService project. However, the community edition of Visual Studio 2017 did compile it (with the change you suggest) and it seems to be working as expected now. Super! That’s another step forward. Thank you (again) :- )
  • You must to post comments
0
0

Luca,

I’ve attached a simple handler test project which does work in vs, but not in owin.

This is basically the example you gave me a while back.

You’ll see the Wisej.HostService.exe in the project, along with a shortcut. The shortcut is for setting the port and localhost in the arguments.

Thanks

Attachment
  • You must to post comments
0
0

Actually, I thought you were implementing a custom handler which need to be registered. But .ashx files don’t need to be registered. I just tried with a self hosted app and the sample ashx added by Visual Studio with Add->New Item->Generic Handler and it works without any registration in web.config with Wisej self hosting.

  • You must to post comments
0
0

All handlers are supported. It also supports owin middleware modules. The handlers have to go in the classic pipeline section. https://msdn.microsoft.com/en-us/library/46c5ddfy.aspx see Classic Mode section. For owin middleware see https://www.scottbrady91.com/Katana/Creating-OWIN-Middleware-using-Microsoft-Katana

  • Darren
    Thanks Luca, but the info in those links might as well be written in Japanese! lol. I really don’t understand it. Why do I have to register the handler when self hosted but don’t have to register it when running from visual studio? This configuring looks specialised, whereas I’m a novice of web apps!
  • Luca (ITG)
    See my updated answer above. You are correct that you don’t need any registration with ashx files. I thought we were talking about custom handlers. It works out of the box without any registration with Wisej owin self hosting. I just tried it and didn’t change anything in the project.
  • Darren
    Hi Luca, No it’s a standard handler & it didn’t work with owin. Win 7 64-bit dev machine. Server & test client all running on same PC. I’ll try again later today. Cheers
  • Darren
    I got error 404, page not found.
  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.