My first time experience: C#/ Asp.net.core
I am planning of deploy my API to my server and error happen.
My source:
I clicked Debug anyway
then this prompt came
You can read the full conversations here .
Follow @Johnmelodyme
My source:
```
using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;using System.Threading.Tasks;using Microsoft.AspNetCore;using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.Logging;
namespace johnTestBO public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); }
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) //Open to loop back localhost // .UseKestrel(options => // { // options.Listen(IPAddress.Loopback, 5001);
.UseStartup(); // }) }}```
The error after I run it in ssh and visual.
```Exception has occurred: CLR/System.Net.Sockets.SocketExceptionAn unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.Private.CoreLib.dll: 'Cannot assign requested address' at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName) at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport.BindAsync() at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass21_0`1.<g__OnBind|0>d.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.d__3.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.d__43.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.d__2.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.d__0.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.d__21`1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.Internal.WebHost.d__26.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.WebHostExtensions.d__5.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.WebHostExtensions.d__4.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host) at johnTestBO.Program.Main(String[] args) in /home/sabrina/Downloads/example/johnTestBO/Program.cs:line 18
First when I deploy the API to the localhost:5001, all work fine until I put everything together in the server. I did
dotnet publish
the project. before this I sudo scp - r
the (all files) relevant project to the server's /home
. dotnet build && dotnet run
, and all work fine. I came to mind that that wasn't a good idea for uploading all files without compounding it. Then I did only upload the 'Publish' folder which had already a 'compound' . As soon as I dotnet build && dotnet run
it in my Visual prompted this error.
Sources:
From the server(using Termius(no longer using puTTY)-Ubuntu):
and also prompted
"MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file."
From My Visual Code Studio:
I clicked Debug anyway
then this prompt came
Then a Professional gave me solid solution, and all I need to do is logical alter a little. Reverse engineering !
He said :"
@johnmelodyme an example:
Create a web webapplication
Publish it:
Copy the publish folder to your server (
/tmp/myserver represents a folder on the server):
On the server:
|
You can read the full conversations here .
Follow @Johnmelodyme