在非管理员帐户下运行自托管OWIN的Web API [英] Running self-hosted OWIN Web API under non-admin account

查看:1150
本文介绍了在非管理员帐户下运行自托管OWIN的Web API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能为自托管OWIN的Web API来下,非管理员帐户下运行?我已经尝试了几十个URL保留,并没有什么作品。该服务无法启动​​与访问被拒绝。它的工作原理,当帐户添加到管理员角色,但我不希望出现这种情况。低于code是Win 7的框架4.5.2运行。

  //安装包microsoft.owin.hosting
//安装包Microsoft.Owin.Host.HttpListenerStartOptions选项=新StartOptions();
options.Urls.Add(HTTP://本地主机:5000 /);
//options.Urls.Add(string.Format(\"http://{0}:5000,Environment.MachineName));
//options.Urls.Add(\"http://+:5000/);
//options.Urls.Add(\"http://*:5000/);使用(WebApp.Start< WebAPISelfHostMinimal.Startup>(期权))
{
    而(!终止)
    {
        等待Task.Delay(10); //保持CPU从得到钉住
    }    LogUtil.LogInfo(终止owin主机。);
}

修改 - 这是下一个Windows帐户下运行。

  C:\\>的netsh的http添加urlacl的http:// +:5000 / USER = mini2012 \\ svcAPIURL保留成功添加C:\\> SC开始apiservice
[SC] StartService失败5:访问被拒绝。C:\\>的netsh的http添加urlacl的http:// *:5000 / USER = mini2012 \\ svcAPIURL保留成功添加C:\\> SC开始apiservice
[SC] StartService失败5:访问被拒绝。C:\\>的netsh的http添加urlacl的http://本地主机:5000 / USER = mini2012 \\ svcAPIURL保留成功添加C:\\> SC开始apiservice
[SC] StartService失败5:访问被拒绝。


解决方案

它看起来像问题是与URL保留。我并不需要一个。如果有一个URL保留,它只会prevent从与拒绝访问错误启动owin主机。此外,对于owin主机的默认端口是5000。如果有一个死的过程仍在运行在该端口上,它将从出发台为您服务。要检查你可以在命令提示符下运行 netstat -a可-b

Is it possible for a self-hosted OWIN Web API to run under a non-administrator account? I have already tried dozens of url reservations and nothing works. The service fails to start with "Access is denied". It works when the account is added to the administrator role but I don't want that. Code below is running on Win 7 framework 4.5.2.

//install-package microsoft.owin.hosting
//install-package Microsoft.Owin.Host.HttpListener

StartOptions options = new StartOptions();
options.Urls.Add("http://localhost:5000/");
//options.Urls.Add(string.Format("http://{0}:5000", Environment.MachineName));
//options.Urls.Add("http://+:5000/");
//options.Urls.Add("http://*:5000/");

using (WebApp.Start<WebAPISelfHostMinimal.Startup>(options))
{
    while (!Terminate)
    {
        await Task.Delay(10); //keep cpu from getting pegged
    }

    LogUtil.LogInfo("Terminating owin host.");
}

EDIT - this is running under a Windows account.

C:\>netsh http add urlacl http://+:5000/ user=mini2012\svcAPI

URL reservation successfully added

C:\>sc start apiservice
[SC] StartService FAILED 5:

Access is denied.

C:\>netsh http add urlacl http://*:5000/ user=mini2012\svcAPI

URL reservation successfully added

C:\>sc start apiservice
[SC] StartService FAILED 5:

Access is denied.

C:\>netsh http add urlacl http://localhost:5000/ user=mini2012\svcAPI

URL reservation successfully added

C:\>sc start apiservice
[SC] StartService FAILED 5:

Access is denied.

解决方案

It looks like the problem was with the URL reservation. I didn't need one. If there is a URL reservation, it will just prevent the owin host from starting with the access denied error. Also, the default port for owin host is 5000. If there is a "dead" process that is still running on that port, it will block your service from starting. To check you can run netstat -a -b at the command prompt.

这篇关于在非管理员帐户下运行自托管OWIN的Web API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆