我写了一个连接到mySQL数据库并提供API的Web服务。当我在Visual Studio中运行它时,它可以正常工作。现在,当我将其放入Internet信息服务中时,我希望它能起作用。但是API不会返回。我的单页应用程序期望此API运行,这给了我下面的错误
GET http://localhost:8024/api/Interviewee 500 (Internal Server Error)
angular.js:15536 Possibly unhandled rejection: {"data":{"Message":"An error has occurred.","ExceptionMessage":"Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.","ExceptionType":"System.InvalidOperationException","StackTrace":" at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)rn at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)rn at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)rn at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)rn at System.Data.SqlClient.SqlConnection.Open()rn at IntervieweeService.Controllers.IntervieweeController.GetInterviewees() in C:\Projects\IntervieweeApp\IntervieweeService\IntervieweeService\Controllers\IntervieweeController.cs:line 30rn at lambda_method(Closure , Object , Object[] )rn at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_1.<GetExecutor>b__3(Object instance, Object[] methodParameters)rn at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)rn--- End of stack trace from previous location where exception was thrown ---rn at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()rn--- End of stack trace from previous location where exception was thrown ---rn at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()rn at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"},"status":500,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"http://localhost:8024/api/Interviewee","headers":{"Accept":"application/json, text/plain, */*"}},"statusText":"Internal Server Error","xhrStatus":"complete"}
(anonymous) @ angular.js:15536
(anonymous) @ angular.js:11815
processChecks @ angular.js:17946
$digest @ angular.js:19075
$apply @ angular.js:19463
done @ angular.js:13312
completeRequest @ angular.js:13569
requestLoaded @ angular.js:13474
load (async)
(anonymous) @ angular.js:13457
sendReq @ angular.js:13257
serverRequest @ angular.js:12998
processQueue @ angular.js:17914
(anonymous) @ angular.js:17962
$digest @ angular.js:19075
$apply @ angular.js:19463
done @ angular.js:13312
completeRequest @ angular.js:13569
requestLoaded @ angular.js:13474
load (async)
(anonymous) @ angular.js:13457
sendReq @ angular.js:13257
serverRequest @ angular.js:12998
processQueue @ angular.js:17914
(anonymous) @ angular.js:17962
$digest @ angular.js:19075
$apply @ angular.js:19463
bootstrapApply @ angular.js:1945
invoke @ angular.js:5122
doBootstrap @ angular.js:1943
bootstrap @ angular.js:1963
angularInit @ angular.js:1848
(anonymous) @ angular.js:36216
fire @ jquery-2.2.4.js:3187
fireWith @ jquery-2.2.4.js:3317
ready @ jquery-2.2.4.js:3536
completed @ jquery-2.2.4.js:3552
连接字符串
Server=localhost;Port=8024;Database=intervieweedb;Uid=rrrr;Pwd=111;
我该如何完成这项工作?谢谢
如果您正在访问网站http://localhost:8024/api/受访者,则Web服务器正在使用端口8024。连接字符串中的Server=localhost;Port=8024
是错误的,因为MySQL需要在其他端口上运行。
将MySQL连接字符串中的Port
更改为MySQL Server的端口号(通常3306
)。