URL 作为 .Net 中 RESTful 服务的参数

URL as param in RESTfull Service in .Net

我正在尝试将 URL 作为参数传递给 REST 服务。

要求: https://LocalHost/api/InsertUrl/{类型},{URL},{注释} https://LocalHost/api/InsertUrl/External,https://www.amazon.com,RANDOM 注意

示例代码:

[HttpPost]
[Route("api/InsertUrl/{Type},{URL},{Notes}")]
public bool SetUrl(string Type, string URL, string Notes)
{

    bool Status = repository.SetupUrl(Type, URL, Notes);
    return Status ;

}

使用 POSTMAN(使用 POST)测试这个终点,我得到 :: 404 - 找不到文件或目录。 您要查找的资源可能已被删除、名称已更改或暂时不可用。

我在这里做错了什么?

IIS 不喜欢 URL 中的点,认为如果它的文件扩展名必须通过另一个模块。

为避免这种情况,您可以通过您的应用程序路由所有请求:

 <configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />

这个问题实际上已经在另一个 post here.

中得到了解答