Handler for Request not found:

12,819

Solution 1

It looks like you're trying to host ServiceStack both at the / root path and at a mixture of /servicestack and /api custom paths. You need to pick one of them, not a combination of all 3. Here is the config if you want to host at the / root path:

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

<!-- Required for IIS 7.0 -->
<system.webServer>
  <handlers>
    <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
  </handlers>
</system.webServer>

The above should replace every other ServiceStack config mapping. Once you've done this you should be able to view the metadata page at:

http://localhost:50097/metadata

Note: If you're running ASP.NET on a port it is unlikely that you also have the Virtual Directory path /ServiceStack.SearchService/.

Solution 2

There is a small step missing from that list that you need if your going to map the services to a custom path. You can find it here:

To quote the missing step:

You also need to configure the root path in your AppHost.

public override void Configure(Container container)
{
    SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api" });
}

Where "api" is the name of the custom path you are using.

Solution 3

I had this exact issue I had and could not find a straight answer to - getting a 403.14 error on the simplest ServiceStack demo.

..:: Simple Answer ::..

Your answer is simple. You have confused your handlers by providing 3 instead of one as mentioned by Mythz. Also, You don't have a specified route for your request.

[Route("/hello")]
public class Hello { public string Name { get; set; } }

This will resolve both your 403.13 error (semantic issue) and you can go to your http://{localdomain}:{port}/hello and actually see the metadata (substitute the {port} with the actual port number IIS Express assigned to you). Without this adjustment, you'll need to go to http://{localdomain}:{port}/metadata.

..:: Detailed Answer ::..

Routing, as it relates to IIS in ServiceStack is done by semantics/convention. Since these routes are dynamic, when IIS is not provided proper routing at run time, it assumes that there is a folder issue (physical path) and throws the 403.14 error. At the same time, if you provide more than one path where there should be only one, bad things happen at run time when everything is wired up.

Just to be sure you have all the essentials, here are all the adjustments you need to make to the original code provided.

a. Adjust the web config file to handle just one path as explored in Mythz response

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

<!-- Required for IIS 7.0 -->
<system.webServer>
  <handlers>
    <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
  </handlers>
</system.webServer>

b. Make the route adjustment described earlier in this post.

Share:
12,819
user742102
Author by

user742102

Updated on June 27, 2022

Comments

  • user742102
    user742102 almost 2 years

    I am building a service stack for the first time: hello world.

    I have followed the step by step guide in here:

    but it is giving me an error: Handler for Request not found: what could be the missing part? thanks.

    here is my global.asax.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.SessionState;
    using ServiceStack.ServiceHost;
    using ServiceStack.WebHost.Endpoints;
    
    namespace ServiceStack.SearchService
    {
        public class Global : System.Web.HttpApplication
        {
            public class Hello { public string Name { get; set; } }
            public class HelloResponse { public string Result { get; set; } }
            public class HelloService : IService<Hello>
            {
                public object Execute(Hello request)
                {
                    return new HelloResponse { Result = "Hello, " + request.Name };
                }
            }
    
    
    
            /// Web Service Singleton AppHost
            public class HelloAppHost : AppHostBase
            {
                //Tell Service Stack the name of your application and where to find your web services
                public HelloAppHost()
                    : base("Hello Web Services", typeof(HelloService).Assembly) { }
    
                public override void Configure(Funq.Container container) { }
            }
    
            protected void Application_Start(object sender, EventArgs e)
            {
                //Initialize your application
                var appHost = new HelloAppHost();
                appHost.Init();
            }
    
    
            void Application_End(object sender, EventArgs e)
            {
                //  Code that runs on application shutdown
    
            }
    
            void Application_Error(object sender, EventArgs e)
            {
                // Code that runs when an unhandled error occurs
    
            }
    
            void Session_Start(object sender, EventArgs e)
            {
                // Code that runs when a new session is started
    
            }
    
            void Session_End(object sender, EventArgs e)
            {
                // Code that runs when a session ends. 
                // Note: The Session_End event is raised only when the sessionstate mode
                // is set to InProc in the Web.config file. If session mode is set to StateServer 
                // or SQLServer, the event is not raised.
    
            }
    
        }
    }
    

    here is my web.config:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <connectionStrings>
        <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <authentication mode="Forms">
          <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
        </authentication>
        <membership>
          <providers>
            <clear />
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
          </providers>
        </membership>
        <profile>
          <providers>
            <clear />
            <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
          </providers>
        </profile>
        <roleManager enabled="false">
          <providers>
            <clear />
            <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
            <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
          </providers>
        </roleManager>
        <httpHandlers>
          <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
          <add path="api*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
        </httpHandlers>
      </system.web>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
          <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
        </handlers>
      </system.webServer>
      <location path="servicestack">
        <system.web>
          <httpHandlers>
            <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
            <add path="servicestack*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
          </httpHandlers>
        </system.web>
        <!-- Required for IIS 7.0 -->
        <system.webServer>
          <modules runAllManagedModulesForAllRequests="true" />
          <validation validateIntegratedModeConfiguration="false" />
          <handlers>
            <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
          </handlers>
        </system.webServer>
      </location>
    </configuration>
    

    I browse it by typing in the browser.

    http://localhost:50097/ServiceStack.SearchService/servicestack/metadata
    
  • Leniel Maccaferri
    Leniel Maccaferri over 11 years
    You're doing a GREAT job with ServiceStack. Just tried the CustomAuthenticationMvc project from here github.com/ServiceStack/ServiceStack.UseCases/tree/master/… and it's working great! :) Keep up the AWESOME work... I plan to call the webservice from a MonoTouch iOS app.
  • D'Arcy Rittich
    D'Arcy Rittich about 11 years
    +1 This seems to be missing from the docs here @mythz
  • Alex.S
    Alex.S almost 11 years
    My reading of the tutorial implied that if you used nuget you wouldn't need to make the web.config entries manually. I had to. ALSO: As pointed out elsewhere if you started with an MVC app you have to comment out the default route - that's what finally fixed it for me.