.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>
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.