Can't get ServiceStack to work in IIS6 with HTTPS

Go To StackoverFlow.com

7

I'm having a problem getting ServiceStack to work with HTTPS in IIS6 and I can't seem to find any documentation on setting this up. Currently I have an endpoint setup like so - http://example.com/api.ashx. When I browse to this, i get the useful ServiceStack generated page which explains the APIs available at http://example.com/api.ashx/metadata. When i browse to https://example.com/api.ashx (notice https) i instead get this error message -

Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /api.ashx

I have the following set up in my web.config (as per example here - http://www.servicestack.net/ServiceStack.Hello/) -

<!-- ServiceStack: Required to host at: /api.ashx -->
    <location path="api.ashx">
        <system.web>
            <httpHandlers>
                <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
            </httpHandlers>
        </system.web>

On my local Windows 7 box i'm running IIS7 and it works just fine but the test and live environments are still using IIS6 and i can't get it to work there.

Other regular aspx pages are working fine when using https.

I'd appreciate anyone who can give me a push in the right direction!

2012-04-04 05:04
by Frank Tzanabetis


9

The problem with IIS 6 is that the IIS 6.0 request pipeline doesn't recognize a path without an ASP.NET extension e.g .aspx doesn't get passed to the ASP.NET isapi hander. So there are generally 2 options for getting this to happen so you can get ServiceStack to run on IIS 6:

  1. Change the servicestack path in Web.Config from '*' to 'servicestack.ashx'

    <system.web>

    <httpHandlers> <add path="servicestack.ashx" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/> </httpHandlers>

    </system.web>

  2. Add a wildcard mapping for your virtual directory to pass all unhandled requests to ASP.NET: Follow these steps to create a wildcard script map with IIS 6.0:

    1. Right-click a website and select Properties
    2. Select the Home Directory tab
    3. Click the Configuration button
    4. Select the Mappings tab
    5. Click the Insert button (see Figure 4)
    6. Paste the path to the aspnet_isapi.dll into the Executable field (you can copy this path from the script map for .aspx files)
    7. Uncheck the checkbox labeled Verify that file exists
    8. Click the OK button

IIS 6.0 Wildcard mapping

2012-04-04 06:06
by mythz
Actually, there was another step i missed (certificate related issue). My bad. This helps though, thanks : - Frank Tzanabetis 2012-04-05 00:01
Tried option 1: i get a 404 error now instead of a handler not found error, Tried option 2: still get the handler not found error, Tried option 1 again after setting the wildcard extension mapping in option 2: 404 error. Any other thoughts here? I'm pretty stumped on getting this to work in IIS6 - kmehta 2015-06-05 18:08


1

mythz answer didn't work for me.

I got it working by adding a location tag to web.config with the servicestack configuration. I found that servicestack worked with path="*" - but took to many requests(Episerver) but solved it like this:

<location path="UniqueTag">
    <system.web>
        <httpHandlers>
            <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
        </httpHandlers>
    </system.web>
</location>

And then prefixed all Routes with the UniqueTag:

[Route("/UniqueTag/DeletePost/{Id}", Verbs = "POST")]

But note that option 2 from mythz's answer might also be required, because it was default setup in our solution.

2014-02-14 07:26
by Morten Holmgaard
Ads