Tuesday, March 29, 2016

Why does Owin.Hosting.StartOptions require admin permissions?

Leave a Comment

I have an application that is making use of Owin's self host functionality.

The application doesn't need administrator permissions but when I use the following code if it's not run as admin I get an exception thrown due to 'access denied'

var options = new StartOptions {     ServerFactory = "Microsoft.Owin.Host.HttpListener" }; options.Urls.Add("http://+:3579/");  using (WebApp.Start<Startup>(options)) { // ..  }  

I need to provide the start options otherwise I get HTTP 503 error (See here)

Here is the exception when run as regular user (non-admin)

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder) at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context) at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context) at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions options) at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options) at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvider services, StartOptions options) at Microsoft.Owin.Hosting.WebApp.Start(StartOptions options) at Microsoft.Owin.Hosting.WebApp.Start[TStartup](StartOptions options) at PlexRequests.UI.Program.Main(String[] args) in C:\Users\Jamie\Documents\GitHubVisualStudio\PlexRequests.Net\PlexRequests.UI\Program.cs:line 93 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() 

Inner exception:Access is Denied

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment