【发布时间】:2020-06-25 15:18:09
【问题描述】:
我在 Visual Studio 2019 的 .net 核心和控制器类中创建了这个 REST API,我有以下代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using RecLoadAPI.DAL;
namespace RecLoadAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RecLoadPrimeController : Controller
{
public IActionResult Index()
{
return View();
}
[Route("RecLoadPrime/insertRecLoadData/{RecStartDate}/{RecEndDate}")]
[HttpPost]
public void insertRecLoadData(string RecStartDate, string RecEndDate)
{
RecLoadDataProvider dataProvider = new RecLoadDataProvider();
dataProvider.InsertCardsData(RecStartDate, RecEndDate);
}
}
}
我正在尝试通过 Postman 测试我的代码,我写了这个 URL:
https://localhost:44306/api/RecLoadPrime/insertRecLoadData/?RecStartDate=01/01/2020&RecEndDate=01/02/2020
在邮递员中,我不断收到错误消息,即未定义名称。我不确定我做错了什么。我对 REST API 很陌生。下面是 Postman 的截图。
下面是我的 PreRequest 脚本的图片:
Pre Request 脚本现在完全是空的。我现在得到一个不同的错误:
HTTP Error 500.30 - ANCM In-Process Start Failure
以下是错误:
<!DOCTYPE html>
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title> HTTP Error 500.30 - ANCM In-Process Start Failure </title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Arial, Helvetica, sans-serif;
font-size: .813em;
color: #222;
background-color: #fff;
}
h1,
h2,
h3,
h4,
h5 {
/*font-family: 'Segoe UI',Tahoma,Arial,Helvetica,sans-serif;*/
font-weight: 100;
}
h1 {
color: #44525e;
margin: 15px 0 15px 0;
}
h2 {
margin: 10px 5px 0 0;
}
h3 {
color: #363636;
margin: 5px 5px 0 0;
}
code {
font-family: Consolas, "Courier New", courier, monospace;
}
body .titleerror {
padding: 3px 3px 6px 3px;
display: block;
font-size: 1.5em;
font-weight: 100;
}
a {
color: #1ba1e2;
text-decoration: none;
}
a:hover {
color: #13709e;
text-decoration: underline;
}
li {
margin: 5px;
}
</style>
</head>
<body>
<h1> HTTP Error 500.30 - ANCM In-Process Start Failure </h1>
<h2> Common causes of this issue: </h2>
<ul>
<li> The application failed to start </li>
<li> The application started but then stopped </li>
<li> The application started but threw an exception during startup </li>
</ul>
<h2> Troubleshooting steps: </h2>
<ul>
<li> Check the system event log for error messages </li>
<li> Enable logging the application process' stdout messages </li>
<li> Attach a debugger to the application process and inspect </li>
</ul>
<h2>
For more information visit:
<a href="https://go.microsoft.com/fwlink/?LinkID=2028265">
<cite> https://go.microsoft.com/fwlink/?LinkID=2028265 </cite></a>
</h2>
</body>
</html>
我们将不胜感激。
【问题讨论】:
-
PreRequest Script 中有什么代码?
-
向我们展示您的预请求脚本。问题与您的应用无关。 Postman 中的 Pre-request 脚本有错误(Pre-request 脚本选项卡)
-
在邮递员中试试这个:
https://localhost:44306/api/RecLoadPrime/insertRecLoadData/01%2F01%2F2020/01%2F02%2F2020你需要对日期进行编码,而且你的 url 也有太多内容。 -
@kristech 错误说: Pre-request 脚本出错!这意味着 Postman 中 Pre-request script 选项卡上的 Pre-request script 有错误
-
曾评论过您将 Query 和 Url 参数混合在一起,但正如@RomanMarusyk 指出的那样,这不是您当前的问题。不过需要注意的地方