【问题标题】:Postman - Web service - IIS 7.5 Detailed Error - 404.0 - Not FoundPostman - Web 服务 - IIS 7.5 详细错误 - 404.0 - 未找到
【发布时间】:2018-06-23 16:25:30
【问题描述】:

我正在运行一个 C# workflow 应用程序。

我添加了一个aspx页面UserUpdate.aspx

还添加了一个web api控制器SynchronisePersonnelXmlFromAwsServiceController.cs

如果我输入,则在 POST 调用中使用邮递员

http://localhost/Workflow/RefreshPersonnel.aspx

我得到正确的响应,页面以 html 显示。

但是,如果我尝试使用以下调用在 SynchronisePersonnelXmlFromAwsServiceController.cs 页面中调用函数 TestCall()

http://localhost/Workflow/SynchronisePersonnelXmlFromAwsServiceController/TestCall

我得到一个 404 未找到 -

<legend>Error Summary</legend>
<h2>HTTP Error 404.0 - Not Found</h2>
<h3>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h3>


  <legend>Most likely causes:</legend>
                <ul>
                    <li>The directory or file specified does not exist on the Web server.</li>
                    <li>The URL contains a typographical error.</li>
                    <li>A custom filter or module, such as URLScan, restricts access to the file.</li>
                </ul>
            </fieldset>
        </div>
        <div class="content-container">
            <fieldset>
                <legend>Things you can try:</legend>
                <ul>
                    <li>Create the content on the Web server.</li>
                    <li>Review the browser URL.</li>
                    <li>Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click 

代码如下:

   namespace Workflow
{

    public class SynchroniseFromAwsServiceController: ApiController
    {
        //// POST api/<controller>
        [HttpPost]
        public string TestCall()
        {
            string xmlFile = "Test XML Test";
            string responseMsg = "Failed Import User";

            if (!IsNewestVersionOfXMLFile(xmlFile))
            {
                responseMsg = "Not latest version of file, update not performed";
            }
            else
            {
                Business.PersonnelReplicate personnelReplicate = BusinessLogic.SynchronisePersonnel.BuildFromDataContractXml<Business.PersonnelReplicate>(xmlFile);
                bool result = Service.Personnel.SynchroniseCache(personnelReplicate);

                if (result)
                {
                    responseMsg = "Success Import Sap Cache User";
                }
            }

            return "{\"response\" : \" " + responseMsg + " \" , \"isNewActiveDirectoryUser\" : \" false \"}";
        }
}
}

【问题讨论】:

    标签: c# postman web-api-testing


    【解决方案1】:

    http://localhost/Workflow/SynchronisePersonnelXmlFromAwsService/TestCall

    请像上面一样删除 SynchronisePersonnelXmlFromAwsServiceController 的控制器。

    【讨论】:

    • 感谢您的回复,但这并没有解决问题
    • 什么是端口运行?
    • 没有接触过端口,但如果它为localhost/Workflow/RefreshPersonnel.aspx工作,那么端口肯定是正确的吗?
    • 我试过 localhost/api/SynchronisePersonnelXmlFromAwsService/TestCall 并且它返回 无法加载文件或程序集 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (来自 HRESULT 的异常:0x80131040) 错误。我重新安装了 Update-Package –reinstall Newtonsoft.Json from stackoverflow.com/questions/22507189/… 但仍然标记
    【解决方案2】:

    请确保您已在 IIS 中安装以下功能,然后重试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 2016-07-10
      • 2011-05-16
      • 2015-02-02
      • 2017-07-28
      相关资源
      最近更新 更多