问题标签 [servicestack-bsd]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
207 浏览

servicestack - How best to code in self-hosted ServiceStack when we can't have session due to null request?

I'm using ServiceStack 3.9.71. I'm going into the self-hosted route to be able to deploy on Linux and still be able to avoid the memory leak issues plaguing Mono.

The thing with self-hosted service is we no longer have the request. Without it, we don't have session as well. Attempts to get the session will fail with

Only ASP.NET Requests accessible via Singletons are supported

due to null request object.

Questions are:

  1. Can someone explain why can't we have the request in the self-hosted ServiceStack service?
  2. How do we get around it?

For example, if the service needs to know the details of the user (e.g what we would have in ICustomAuthSession) who invoked the request, how do we do that? I can see that the Cache actually contains the session, but since we don't have the request then there's no SessionKey that we can use to grab the session from the Cache. I somewhat see some discussion on it, but can't quite make out what to do exactly.

0 投票
1 回答
349 浏览

c# - ServiceStack ServiceExceptionHandler.Add 方法不存在?

我正在使用 ServiceStack 版本 3.9.71,但找不到“添加”方法。wiki上的文档是否已过时?我应该怎么做才能使它工作?

0 投票
1 回答
75 浏览

servicestack - 服务类具有未解析的公共属性

我很难理解为什么我的 Manager 类在通过 Service 类中的这个示例 POST 方法处理请求的上下文中为空。我注册了 Manager 和它的依赖项,就像这个例子一样,它似乎注册得很好。我可以让它工作的唯一方法是,如果我告诉属性去并通过 apphost 引用中的容器来 resolveNamed。谢谢!

0 投票
1 回答
535 浏览

servicestack - 如何在我的 ServiceStack 托管测试中绕过“HttpListenerBase.Instance 已设置”?

我有一个基于 ServiceStack 3.9 构建的项目,具有广泛的测试覆盖率,它使用 ServiceStack 的自托管 API 工具。

我的很多测试装置看起来像这样:

问题是,如果当测试失败时,TearDown 似乎并不总是干净地运行 - 然后项目上的所有其他测试都失败并出现相同的错误,要么

System.IO.InvalidDataException:已经设置了 HttpListenerBase.Instance

或不那么频繁

无法监听前缀http://localhost:60666/,因为它与机器上的现有注册冲突

发生这种情况时,整个测试套件会在几分钟内无法运行 - 大概是在某些底层网络绑定超时或被处置时?- 然后几分钟后它又开始工作了。

我怎样才能更优雅地处理这个问题?有什么方法可以http://localhost:60666/在初始化我的 AppHost 之前强制处置/取消注册该端点,所以它会在启动新的服务主机之前杀死任何现有的服务主机?当一个“正确”的失败测试导致 1,000 多个测试失败时,要弄清楚发生了什么变得越来越困难,因为其他测试无法初始化它们的 HTTP 侦听器。

0 投票
1 回答
356 浏览

c# - ServiceStack 中的路由 /json/syncreply 来自哪里?

我正在尝试使用此 DTO 向第三方 api 发送请求:

客户要求:

Not Found目前正在收到回复。当我发送到http://使用 Fiddler 时,我可以看到/json/syncreply添加了路径,即../api/v1/json/syncreply> 我希望了解它的来源以及如何确保我的请求在正确的路径上发送。

干杯

0 投票
1 回答
474 浏览

c# - Using ServiceStack OrmLite to create Key Value table for dynamic types

I want to create a key value table in my database along the lines of

Using a slightly modified SqlProvider I have no problems getting CreateTable<KeyValue>() to generate varchar(1024) Id, varchar(max) Value.

I have no issues saving objects to it. The problem is when I load the objects

content.Value at this point is a string.

Looking at the database record, the text for value does not appear to store any type information.

Is there really anything I can do better other than manually invoking ServiceStack.Text and call deserialize with the appropriate type information?

I do not need absolute dynamic, my actual use case is for polymorphism with a base class instead of dynamic. So I don't really care what type Value is whether it's the base class, dynamic, object, etc. Regardless other than using the class

I haven't been able to get anything other than a string back for Value. Can I tell OrmLite to serialize the type information to be able to correctly deserialize my objects or do I just have to do it manually?

Edit: some further information. OrmLite is using the Jsv serializer defined by ServiceStack.Text.TypeSerializer and is in no way pluggable in the BSD version. If I add a Type property to my KeyValue class with the dynamic Value I can do

I just really want a better way to do this, I really don't like an object of 1 type going into the db coming back out with a different type (string).

0 投票
2 回答
494 浏览

servicestack-bsd - 执行凭证认证后的 Servicestack 未授权异常

我正在尝试使 Servicestack Credentials 身份验证正常工作,但是当我尝试使用装饰有的受保护服务时,[Authenticate]即使身份验证成功,我也会收到未经授权的异常。这里错过了什么?

AppHost 看起来像这样:

我认为我TryAuthenticate正确地覆盖并且从 Swagger 一切正常。问题在于客户端调用 - 在针对 myurl/auth/ 的身份验证成功之后 - 对不同服务的下一次调用失败并出现未经授权的异常。请问有什么想法吗?

经过更多研究:看起来需要将 ss-id/ss-pid cookie 传递给受限资源以进行身份​​验证。我怎样才能做到这一点?

0 投票
1 回答
367 浏览

web-services - 在 Service Stack 3.9 中配置 web.config 不起作用

我正在学习 ServiceStack 教程,但我使用 3.9.71 版本并修改 web.config 时出现错误。我的代码是这样的:

0 投票
1 回答
191 浏览

asp.net - ServiceStack maxReceivedMessageSize

我有一个使用 servicestack v3.9 编写的服务。我正在尝试返回一个大型结果集,并且在我的客户端上收到 500 内部服务器错误。如果我查看错误的详细信息,我会看到结果列在异常中,但在 65536 个字符后被截断。我知道这是.net 施加的默认限制。我不知道如何为服务堆栈增加它。

我的客户端没有使用 Web 配置中的绑定连接到服务,因为它正在使用服务堆栈。对于 web api 调用,这似乎是您要解决此问题的地方,即在绑定中增加 maxReceivedMessageSize。我猜也有一些方法可以增加服务堆栈的这个限制??

0 投票
1 回答
200 浏览

dll - 无法从 NUGet 获取 NLog 2.0.1 版本

在 Visual Studio 2010 中,在包管理器控制台中,我键入:

我得到了2.0.0(在磁盘上)。在Codeplex上没有2.0.1版本。由于错误,ServiceStack.Logging.NLog 需要2.0.1版本:

2.0.1版也列在 NuGet 可用包中。

我已经替换了最新的ServiceStack v3 快照NLog.dll中的文件,并且我的程序运行良好(ASP .Net4 Web 应用程序),但这不是很长时间的解决方案。在 ServiceStack中,快照是2.0.01.0.8ServiceStack.Logging.NLog.dllNLog.dllServiceStack.Logging.NLog.dll