xcopy是否可以部署自托管的ASP.NET Web API控制台应用程序?

时间:2013-03-20 11:47:28

标签: asp.net-web-api

根据this tutorial,自托管的ASP.NET Web API应用程序必须以管理员身份运行,或者某人必须在将运行该应用程序的计算机上运行netsh http add urlacl命令。

我有一个控制台ASP.NET Web API应用程序,我希望部署过程尽可能简单。有没有办法设置应用程序,以便可以部署xcopy?

1 个答案:

答案 0 :(得分:3)

这是Windows UAC限制。如果您的应用程序需要侦听特定端口,则需要一些特权。除非您以管理员身份运行应用程序,否则您必须运行netsh以授予运行应用程序的Windows帐户的权限以打开该端口。您可以向控制台应用程序添加清单,以强制它始终以管理员身份运行。

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator"></requestedExecutionLevel>     
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

问候
巴勃罗。