Hosting the pit of ASP. NET core in Windows services

Source: Internet
Author: User
Tags hosting

Follow the official website tutorial

https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-2.1&tabs= Aspnetcore2x

Copy the official demo code,

Https://github.com/aspnet/Docs/tree/master/aspnetcore/host-and-deploy/windows-service/sample

Create an ASP. NET Core MVC project. Release to d:\svc with release.

Then open PowerShell, enter command, error

SC create MyService binpath= "D:\svc\MvcService.exe"

Set-content: Could not find positional formal parameters that accept the actual parameter "Binpath=d:\svc\mvcservice.exe".

Location Line: 1 characters: 1

+ SC Create myservice binpath= "D:\svc\MvcService.exe"

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ categoryinfo:invalidargument: (:) [Set-content],parameterbindingexception

+ Fullyqualifiederrorid:positionalparameternotfound,microsoft.powershell.commands.setcontentcommand

Feel strange, command and official website exactly the same, how is wrong? All kinds of tossing and shaking are uncertain.

Consider a traditional command prompt for the tools used on the official website, so change it. The latest version of WIN10, right click on the Start menu, there is no command prompt. Left-click Start menu, keyboard cmd, you can find the command prompt tool, at this time also with the right button, run as Administrator, very troublesome.

However, the service was successfully installed!

Visit http://localhost:5000 to see the Web page.

No words, I always think PowerShell is an upgrade of CMD, forward-compatible, did not expect this pit.

Finally, using SC delete MyService to delete the service, the discovery service is still in, just stopped and disabled. I don't know if it's right.

Hosting the pit of ASP. NET core in Windows services

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.