0

I've a very similar scenario to this question, namely I want a static file server which serves an index.html as the base of my angular app.

However when I try to access the page, I get the "This webpage is not available" ERR_CONNECTION_REFUSED error in Chrome.

I took a peek in fiddler, where the error is:

[Fiddler] The connection to 'localhost' failed. 
Error: ConnectionRefused (0x274d). 
System.Net.Sockets.SocketException No connection could be made 
because the target machine actively refused it 127.0.0.1:3340

I did the following:

Created a new Empty ASP.NET 5 Template. Added an empty index.html to the wwwroot folder. Added the following code to the Startup.cs:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseIISPlatformHandler();
    app.UseFileServer();
}

The project.json file contains the following dependencies:

"dependencies": {
  "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
  "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
  "Microsoft.AspNet.StaticFiles": "1.0.0-rc2-15978"
},

while the global.json is

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-rc1-final"
  }
}

The strange thing is that if I create an MVC project, then replace its complete Startup.cs code with the two lines above it works like a charm.

So the question is: what do I need to make this work when I'm using an Empty template?

1 Answer 1

1

Try setting Microsoft.AspNet.StaticFiles version to 1.0.0-rc1-final. Your issue may be caused by exception because of package incompatibility.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, this solved the issue, thanks. I still cannot believe it was as simple as this :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.