用于寻址在唯一标识符中包含句点的条目的 OData URI 约定?

发布于 2024-12-08 07:31:40 字数 478 浏览 1 评论 0原文

我在应用程序中使用 OData 作为 api。我的一个数据库表有一个包含句点 (.) 的唯一 ID,我尝试使用以下约定访问该表中的条目:

http://foo.bar.com/services/v001.svc/Categories('ABC')

..但我不断收到以下错误:

路径“/services/v001.svc/Categories('ABC')”的控制器未找到或未实现 IController。

我最初认为这是由于我的路线配置错误造成的,但我删除了所有自定义路线,但仍然遇到相同的错误。通过相同的 uri 约定访问我的数据库中所有表中的所有其他条目效果很好。这些条目与所有其他条目之间的唯一区别是我在唯一标识符列中使用了句点。

帮助!

I am using OData as an api within an app. One of my database tables has a unique id that contains periods (.) I'm trying to access the entries in that table using the the following convention:

http://foo.bar.com/services/v001.svc/Categories('A.B.C')

..but I'm continually receiving the following error:

The controller for path '/services/v001.svc/Categories('A.B.C')' was not found or does not implement IController.

I initially thought this was due to a mis-configuration in my routes but I removed all custom routes and still get the same error. Accessing all other entries in all tables within my database via the same uri convention works just fine. The only difference between these entries and all others is that I use a period in the unique identifier column.

Help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深巷少女 2024-12-15 07:31:40

问题是 Cassini(Visual Studio 中的开发 Web 服务器)在处理 URL 中的句点时存在问题。解决方案是更改项目的属性以使用本地 IIS Web 服务器而不是使用 Cassini。为此:

  1. 右键单击您的项目
  2. 单击“属性”
  3. 单击“Web”选项卡
  4. 将“服务器”下的设置更改为“使用本地 IIS Web 服务器”,并选中“使用 IIS Express”
  5. 按照提示创建虚拟目录等 下次调试时,
  6. 您的应用程序应该在本地 IIS 安装上运行,并且现在应该可以正确处理 URL。

当然,这假设您的 PC 上安装了 IIS。为什么 Cassini 不喜欢句点而完整的 IIS 喜欢?谁知道?

The probelm is that Cassini (the development web server within Visual Studio) has a problem handling periods in a URL. The solution is to change the project's properties to use a Local IIS Web Server instead of using Cassini. To do this:

  1. Right clisk on your project
  2. Click "Properties"
  3. Click the "Web" tab
  4. Change the settings under "Server" to "Use Local IIS Web server", and check "Use IIS Express"
  5. Follow prompts to create virtual directory, etc.
  6. Next time you debug, your app should be running on your local IIS installation and the urls should now be handled correctly.

This of course assumes you have IIS installed on your PC. Why Cassini doesn't like periods and full IIS does? Who knows?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文