- Add Website and created folder eg . c:\iis\myapi
- Change Application Pool to No Managed Code
- Check Security of Folder, add
- IIS_IUSRS
- IIS AppPool\myapi
- Browse Created Website (should result in HTTP Error 403.14 – Forbidden to list contents cause nothing is in)
- Create new repo eg github
- Create new VisualStudio ASP.NET Core API
- Run and Debug
- try api endpoints
- publish to target Folder (best case: separate folder to copy after publish)
- Copy contents (using TeraCopy eg , resp. diff sync tool)
- try sampleendpoint
- take care that Swagger is not configured to show in default so dont despair
- commit your state if working
- checking git status is everything is correctly tracked.
- rename WeatherForecast to dream name best with eg. Notepad++ replace all and change files names in VS later on.
- test run and debug
- publish again
- test it on local IIS.
works till here. so integrate biz logic and repeat small steps cycle step by step.
sources of error investigation:
custom err exc handling
API functional, but problems showing swagger site. steps:
- had to check security of the COM object:
due to Event Viewer error desc
Category: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer
EventId: 2
SpanId: cb7174b3e1054a29
TraceId: 789b2e9b100bdb4d3fe6ed8e154135f1
ParentId: 0000000000000000
RequestId: 80000006-0007-ff00-b63f-84710c7967bb
RequestPath: /Keo/CreateKeoObj
Connection ID "18374686511347007489", Request ID "80000006-0007-ff00-b63f-84710c7967bb": An unhandled exception was thrown by the application.
Exception:
System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {82EAAE85-00A5-4FE1-8BA7-8DBBACCC6BEA} failed due to the following error: 80070005 Access is denied. (0x80070005 (E_ACCESSDENIED)).
at System.RuntimeTypeHandle.AllocateComObject(Void* pClassFactory)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
at KeoCoreApi.KeoObj.CreateKeoInstance() in C:\git\keolabs\KeoCoreApi\KeoObj.cs:line 18
at lambda_method4(Closure , Object , Object[] )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()
Next steps if resolved: test from different computer, intranet:
- connect to ip host and port
- if connection is not working through, check firewall rules.
- go to advanced settings
- open up required port by adding Inbout Rule Port
- test api from network computer
- add /swagger , respectively the desired endpoint to url
.