【发布时间】: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