1

I want to change the local host name so http://localhost/app1 could, say, become http://app1 - for a few different ASP.net Core 2.1 MVC websites.

I'm using IIS in Windows 10. (I have all sorts of reliability issues with IIS Express every time I try it - I'd rather use full IIS).

I've followed this article: https://www.mojoportal.com/adding-a-host-name-to-the-hosts-file-for-local-testing

changing the hosts file then adding new websites in IIS rather than adding applications under the default website.

I want to do this for various reasons including preventing passwords from autofilling across many websites on localhost.

This works fine on MVC 5 sites - but in .net Core 2.1 MVC sites I get a

HTTP Error 502.5 - Process Failure

If I look in the log - and I've tried this on various sites - I get an error such as this:

An assembly specified in the application dependencies manifest (AppName.deps.json) was not found: package: 'Stripe.net', version: '19.8.0' path: 'lib/netstandard1.2/Stripe.net.dll'

This doesn't only happen for Stripe.

The deps.json file I guess is being dynamically created - I can't find it. The sites deploy to the server fine.

Why does this happen - and how can I change hostname away from localhost for .net core 2.1 MVC sites?

If I create a template .net Core 2.1 MVC site it lets me do it fine, strangely but can see no obvious differences.

I can't find anything on Google directly about this though I've looked for a few hours.

I found this - but it didn't help: ASP .NET Core 2.0 Change "localhost" to a "hostname"

Thanks.

Update

A vanilla .net core mvc 2.1 application works fine but as soon as 1 nuget package is installed this error happens again:

An assembly specified in the application dependencies manifest (hosttest.deps.json) was not found

So there's some path issue to nuget packages - can't find how to fix it though.

niico
  • 11,206
  • 23
  • 78
  • 161
  • How are you hosting it? Are you trying to run it on visual studio? – Marcel Sep 24 '18 at 21:48
  • IIS............. – niico Sep 24 '18 at 21:57
  • follow this: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.1 and you should be fine – Marcel Sep 24 '18 at 22:02
  • @Marcel thanks, I've seen that doc - but how does this let me change localhost/app1 to app1 for each app I want to change the host name of on a dev machien? – niico Sep 24 '18 at 22:08
  • Well if you added it in your hostfile, and added a binding in IIS It should work. I believe you missed a setting for asp.net core. Like installing asp.net core runtime (like it says in the doc). ASP.NET Core has different requirements than MVC 5. – Marcel Sep 24 '18 at 22:13
  • see update......... – niico Sep 24 '18 at 22:25
  • Gotta love the unexplained drive by downvote. – niico Sep 24 '18 at 22:36
  • Ah i think i know. I had this issue many times. Are you doing a self-contained build? When you add a new reference you can't just add the DLL's, you have to update everything in the folder. – Marcel Sep 24 '18 at 22:38
  • I'm not sure I follow - if I just create a brand new .net core 2.1 mvc app it works - if I add 1 nuget package, then the issue happens. – niico Sep 24 '18 at 23:41
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/180699/discussion-between-marcel-and-niico). – Marcel Sep 24 '18 at 23:42
  • Have you tried publishing your .NET Core project? You then point IIS to your published folder. bin\Debug\netcoreapp2.1\publish The issue with this, is that you will have to publish each time you make changes to the code base. – Emma Middlebrook Sep 27 '18 at 08:34
  • I haven't but you're right that would make my workflow way less efficient. I've decided to just use aliases for localhost (eg localhost2, localhost3/myapp) < it fixes the same problems and is super easy to do. – niico Sep 27 '18 at 12:17

0 Answers0