6

After upgrading to Beta 8, debugging using the windows authentication doesn't work in IIS Express. I am getting an error

"An error occurred attempting to determine the process id of the DNX process hosting your application."

Steps to reproduce:.

  1. Create a new project and choose Empty web template.
  2. In the project settings, change the IIS Express settings to use Windows Authentication. Uncheck the anonymous authentication.
  3. Enable SSL.
  4. Debug the project.
  5. Error comes up.

I am using new installation of Windows and Visual Studio. Do I need to download any additional software apart from the installation files?

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
Sam
  • 281
  • 5
  • 15
  • Thanks. My issue occurs with project created using Beta 8 and not during the upgrade. Any idea why? – Sam Oct 18 '15 at 00:43
  • I have exactly the same problem Sam - works perfectly with Windows Authentication unticked, tick it and it no longer works. I've gone through everything recommended in the answer mentioned by @pj-mahoney and nothing seems to help. – Mark Hughes Oct 19 '15 at 17:02
  • It looks like this is a tooling bug - see [this open issue](https://github.com/aspnet/Hosting/issues/419) - I'm trying to work out a workaround and will post an answer if I do. – Mark Hughes Oct 19 '15 at 17:18
  • @Sam I've posted a workaround as an answer, have a look and see if that helps you out. – Mark Hughes Oct 19 '15 at 18:46
  • Great to hear the workaround. I am not able to compile even after adding the reference to "Microsoft.AspNet.Server.WebListener": "1.0.0-beta8". Error : IfeatureCollection doesnot contain definition of Get. Any other reference I need to add for Beta 8? – Sam Oct 19 '15 at 19:41
  • Ooh I came across that problem too - I'm not at work any more but let me try and remember how I fixed it... I think I added a reference to another framework package... Try pushing Ctrl and . on that line and seeing if there's a suggestion to add a package? – Mark Hughes Oct 19 '15 at 21:01
  • @Mark. I was able to fix the compilation issue. Running in web mode works fine for windows Authentication. Thanks for your help. – Sam Oct 20 '15 at 14:41
  • @Sam no worries - what was the fix (so I can add it to the answer if needed)? – Mark Hughes Oct 20 '15 at 14:42
  • @Mark. I added reference to "Microsoft.AspNet.Server.WebListener" : "1.0.0-beta8", and "Microsoft.Net.Http.Server": "1.0.0-beta8". We have to add following namespaces to startup.cs using Microsoft.AspNet.Http.Features; using Microsoft.Net.Http.Server; – Sam Oct 20 '15 at 14:50

1 Answers1

3

As noted in the comments, there is an open tooling issue for this bug. In the mean time, I've been able to successfully debug using WebListener which needs the following two changes:

In Startup.cs

using Microsoft.AspNet.Http.Features;
using Microsoft.Net.Http.Server;

and in the Configure method add:

var listener = app.ServerFeatures.Get<WebListener>(); 
if (listener != null)
{ 
    listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM; 
}

In project.json add a new weblistener command as follows:

"commands": {
  "weblistener": "Microsoft.AspNet.Server.WebListener --config hosting.ini",
  "web": "Microsoft.AspNet.Server.Kestrel"
},

and ensure you have WebListener in your dependencies section

"Microsoft.AspNet.Server.WebListener": "1.0.0-beta8",

As I was upgrading from beta 7, I had to change my hosting.ini file into json format - don't know if that's important or not!

Once this is done, you should be able to debug using weblistener instead of IIS Express. Using web (i.e. kestrel) to debug does not work, as kestrel does not (and will not) support NTLM authentication.

I found that if I changed the "web" command directly in project.json, Visual Studio helpfully changes it back to kestrel rather aggressively, so adding a separate command as recommended by the Microsoft team seems to keep everything happy.

fiat
  • 15,501
  • 9
  • 81
  • 103
Mark Hughes
  • 7,264
  • 1
  • 33
  • 37
  • @Sam I've updated this answer slightly as I found that Visual Studio kept changing my "web" command back to Kestrel no matter what I did. Let me know if this doesn't work for you. – Mark Hughes Oct 20 '15 at 08:45