ServiceStack从V3升级到V4导致成功构建,但在运行时为500

时间:2014-06-03 17:20:34

标签: c# asp.net .net servicestack

我最近获得了ServiceStack V4的许可,并从V3完成了整个升级过程。一切似乎都很好,但由于某种原因,我在运行时遇到500错误。由于重命名,我确保了web.config中引用的正确HttpModule。它目前引用ServiceStack.HttpHandlerFactory。我还检查了IIS Express日志,它们不是很有帮助。它似乎只是说它在BeginRequest中失败了。

我似乎无法使用Log4Net获取任何日志记录或调试信息。我看到来自RavenDB的信息会进入日志,但ServiceStack本身并没有。它似乎只是默默地失败了500。

我确切知道的是,如果我使用ServiceStack许可证appSetting,我会得到预期的许可例外。如果我有许可证,它只是给我这个通用500.

这是日志文件中的内容

2014-06-03 15:08:58,991 [1] DEBUG Raven.Client.Document.SessionOperations.QueryOperation [(null)] - Executing query 'ServiceName:PracticeManagement' on index 'dynamic/ApiClientAuths' in 'https://ravendb.someurl.com (DB: DB);DB'
2014-06-03 15:08:59,144 [1] DEBUG Raven.Client.Document.SessionOperations.QueryOperation [(null)] - Query returned 1/1 results
2014-06-03 15:08:59,168 [1] DEBUG Raven.Client.Document.SessionOperations.QueryOperation [(null)] - Executing query 'ServiceName:PracticeManagement' on index 'dynamic/ApiClientAuths' in 'https://ravendb.someurl.com (DB: DB);DB'
2014-06-03 15:08:59,251 [1] DEBUG Raven.Client.Document.SessionOperations.QueryOperation [(null)] - Query returned 1/1 results

以下是对Configure

的调用
public override void Configure(Container container)
{
    //Set JSON web services to return idiomatic JSON camelCase properties
    JsConfig.EmitCamelCaseNames = true;

    SetConfig(new HostConfig { DebugMode = true });
    //logging
    LogManager.LogFactory = new Log4NetFactory(true);

    //Using an in-memory cache
    container.Register<ICacheClient>(new MemoryCacheClient());

    //Configure SQL database
    ConfigureSqlDb(container);
    ConfigureCrossSystemProviders(container);
    //Configure RavenDB
    this.ConfigureRavenDb("RavenDB");
    //Enable ApiKeys
    this.ConfigureApi("PracticeManagement");
    //Enable validation
    this.ConfigureValidation(typeof(GetRecipes).Assembly);
    //Enable Authentication
    ConfigureAuth(container);       
    //Enable exception management
    this.ConfigureElmah();
    //Configure CDE data
    ConfigureCdeProviders(container);
}

以下是web.config中的一些代码

<system.web>
  <compilation debug="true">
    <assemblies>
      <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </assemblies>
  </compilation>
  <httpModules>
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
    <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
    <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
  </httpModules>

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

现在是webserver标签

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />

    <handlers>
      <add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
    </handlers>
  </system.webServer>

1 个答案:

答案 0 :(得分:1)

我发现了问题。这是在ConfigureApi方法调用中,并且与未正确发生的Funq解决方案有关。我仍然不知道依赖解析的问题是什么,但我不再发生模糊的HTTP 500故障。