2012-05-14 22 views
8

私は最初にサービススタックを構築しています:hello world。要求のハンドラが見つかりません:

私はhereでステップバイステップガイドに従っている:

を、私にエラーを与えている:ハンドラが見つからない要求のために:欠品何ができますか?ありがとう。ここ

は、ここに私の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. 

     } 

    } 
} 

である私の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> 

私はブラウザに入力して、それを参照します。

http://localhost:50097/ServiceStack.SearchService/servicestack/metadata 

答えて

7

あなたは/ルートパスでと/servicestack/apiカスタムパスの混合物でServiceStackの両方をホストしようとしているようです。あなたは/ root pathでホストする場合はここではすべての3の組み合わせが設定され、それらのいずれかを選択する必要はありません。

<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> 

上記の他のすべてのServiceStackの設定マッピングを交換する必要があります。

http://localhost:50097/metadata

注:あなたがポート上でASP.NETを実行している場合、あなたがまた、仮想ディレクトリのパスを持っていることはほとんどありませんあなたがこれを実行したら、あなたはでメタデータのページを表示することができるはずです/ServiceStack.SearchService/

+0

あなたは 'ServiceStack'で素晴らしい仕事をしています。 'CustomAuthenticationMvc'プロジェクトはhttps://github.com/ServiceStack/ServiceStack.UseCases/tree/master/CustomAuthenticationMvcから試してみました。 :)素晴らしい仕事を続けてください...私はMonoTouch iOSアプリケーションからwebserviceを呼び出す予定です。 –

+0

thx - 楽しんでよろしいですか:) – mythz

+0

チュートリアルを読んだことは、あなたがnugetを使用した場合、web.configエントリを手動で作成する必要がないことを暗示しています。そうしなければならなかった。 ALSO:MVCアプリケーションを使い始めると、どこか別のところで指摘されているように、デフォルトルートをコメントアウトする必要があります。 – GeorgeBarker

11

サービスをカスタムパスにマッピングする場合に必要な、そのリストから欠落している小さなステップがあります。 You can find it here

が欠落しているステップを引用すると:

"api"は、使用しているカスタムパスの名前です

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

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

+1

+1これはドキュメント[ここ](http://servicestack.net/ServiceStack.Hello/)@mythz – RedFilter

+0

から不足しているようだこの問題を解決しました。 – saille

2

私はこの正確な問題を抱えていました。最も単純なServiceStackデモで403.14エラーが発生しました。

.. ::単純な答え:: ..

あなたの答えは簡単です。 Mythzに言及されているものの代わりに3つを用意することによって、ハンドラを混乱させました。また、あなたのリクエストに指定されたルートがありません。

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

これは、両方のあなたの403.13エラー(セマンティック問題)を解決し、あなたがあなたのhttpに行くことができます:// {LOCALDOMAIN}:{ポート} /ハローと実際とのメタデータ({ポート}を置き換えを参照してくださいあなたに割り当てられた実際のポート番号IIS Express)。この調整がなければ、http:// {localdomain}:{port}/metadataにアクセスする必要があります。

.. ::詳細回答:: ..

ルーティングは、ServiceStackのIISに関連しており、セマンティクス/規則によって行われます。これらのルートは動的なので、実行時にIISに適切なルーティングが提供されないと、フォルダの問題(物理パス)があるとみなされ、403.14エラーがスローされます。同時に、1つしかない場所に複数のパスを指定すると、すべてが配線されているときに実行時に悪いことが起こります。

すべての必須事項があることを確認してください。提供されている元のコードに加える必要があります。

a。 Web設定ファイルを調整して、Mythzレスポンスで調べるように1つのパスのみを処理します。

<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。この記事の前半で説明したルート調整を行います。

関連する問題