1

.css (and other) 404 errors after changing Web Server Settings App URL: port number in VS2015.

I've created a blank Asp.net Core 1.0 MVC 6 web page project from the project template, added a controller, added some binding so I could hit it from my mobile browser on the nat, Hit F5 all is good.

I decided I wanted a full web page, after some research, I thought it would be easier to just delete the first web site and recreate as a full (not blank) web site. I wanted to keep the same project name in my solution. This app worked fine showing the images, and carousal that comes in the default template. I added my controller which worked too.

I changed the Web Server Settings App URL: port number as I have my mobile app using the original dev port. Not so good 404 errors on content in css and images folders.

I tried cleaning browser cache. Rebuilt web project. Restarted VS. Killed off Microsoft.VsHub.Server.HttpHostx64.[exe|com].

This SO post suggested some acl changes. I tried these.

netsh http delete urlacl url=http://localhost:60262/
netsh http add urlacl url=http://*:60262/ user=everyone

This is from my applicationhost.config (desired port is 60262 was 61044)

  <site name="MissD.Web" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
      <virtualDirectory path="/" physicalPath="C:\Users\jeffa\Source\Workspaces\Miss Direction\MissDirection\MissD.Web\wwwroot" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:60262:192.168.1.176" />
      <binding protocol="http" bindingInformation="*:60262:localhost" />
    </bindings>
  </site>
Community
  • 1
  • 1
Jeff Albrecht
  • 3,723
  • 1
  • 17
  • 22
  • Most likely someone else is using the port. For example, Skype used to use 8888 and cause me problems all the time. Are you using IISExpress? – Shawn Wildermuth Feb 01 '16 at 23:48
  • Yes IISExpress. I've been using the desired port for several days,even moments before. The site serves .html but not .css and images. I tried it in Kestrel with the same result. – Jeff Albrecht Feb 02 '16 at 00:00
  • Tried a previously unused port for this project (neither of those that I previously used). Same results. Put it back to the original port 61044 and .css works again. – Jeff Albrecht Feb 02 '16 at 02:19

1 Answers1

0

I'm Donkey again from my Assumptions. I don't know why it was working at all, I'm very curious about that, with the default port created by VS on project creation with the following in startup.cs

// app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions()
{
    FileProvider = new PhysicalFileProvider(@"C:\Images"),
    RequestPath = new PathString("/StaticImageFiles")
});

I changed it to

app.UseStaticFiles();
app.UseFileServer(new FileServerOptions()
{
    FileProvider = new PhysicalFileProvider(@"C:\Images"),
    RequestPath = new PathString("/StaticImageFiles"),
    // EnableDirectoryBrowsing = true
});

Working now. Tried changing app URL: several times. No problem.

Jeff Albrecht
  • 3,723
  • 1
  • 17
  • 22