I am trialling the WebApi Self Hosting sample and am getting an error 101: connection was reset (in chrome). I am new to MVC so I know I haven't done something right but this appears to be very straight forward.
1) I installed MVC 4.
2) I grabbed self host and dependencies from NuGet.
3) I have implemented code as in Derek Whittaker's blog post but it is almost identical to Mike Wasson's "Self-Host a Web API" on this site.
5) I originally used port 8080 but changed the code to use port 9000 because my TFS is using 8080 and I was concerned about a conflict... for the record same result anyway.
6) Try to open http://localhost:9000/endpoints/episode and get an error 101. If the service isn't running I get a "url is broken" message so something is working. I've disabled my firewall, etc. I've checked my windows logs and there is nothing apart from
some messages from TFS (which stopped when I started using port 9000).
aewilson
Member
5 Points
3 Posts
WebApi Self Hosting Sample Error 101
Mar 18, 2012 11:02 AM|LINK
I am trialling the WebApi Self Hosting sample and am getting an error 101: connection was reset (in chrome). I am new to MVC so I know I haven't done something right but this appears to be very straight forward.
1) I installed MVC 4.
2) I grabbed self host and dependencies from NuGet.
3) I have implemented code as in Derek Whittaker's blog post but it is almost identical to Mike Wasson's "Self-Host a Web API" on this site.
http://devlicio.us/blogs/derik_whittaker/archive/2012/02/27/zero-to-self-hosting-aspnet-webapi-in-a-few-short-steps.aspx?CommentPosted=true#commentmessage
4) I register my port with netsh:
netsh http add urlacl url=http://+:9000/ user=[domain\user]
5) I originally used port 8080 but changed the code to use port 9000 because my TFS is using 8080 and I was concerned about a conflict... for the record same result anyway.
6) Try to open http://localhost:9000/endpoints/episode and get an error 101. If the service isn't running I get a "url is broken" message so something is working. I've disabled my firewall, etc. I've checked my windows logs and there is nothing apart from some messages from TFS (which stopped when I started using port 9000).
Any help would be appreciated.
panesofglass
Member
730 Points
237 Posts
Re: WebApi Self Hosting Sample Error 101
Mar 18, 2012 01:32 PM|LINK
aewilson
Member
5 Points
3 Posts
Re: WebApi Self Hosting Sample Error 101
Mar 18, 2012 07:45 PM|LINK
(Should be) as per code in Derek's post I mentioned above, but to be sure...
Program.cs
static void Main(string[] args) { var selfHostConfiguraiton = new HttpSelfHostConfiguration("http://localhost:9000"); selfHostConfiguraiton.Routes.MapHttpRoute( name: "DefaultApiRoute", routeTemplate: "endpoints/{controller}", defaults: null ); using (var server = new HttpSelfHostServer(selfHostConfiguraiton)) { server.OpenAsync().Wait(); Console.WriteLine("Hosting at http://localhost:9000/endpoints/{controller}"); Console.ReadLine(); } }EpisodeController.cs
public class EpisodeController : ApiController { public IList GetAllEpisodes() { return new List<Episode> { new Episode {Id = 1, Name = "Episode 1", ReleasedOn = DateTime.Now.AddDays( -10 )}, new Episode {Id = 2, Name = "Episode 2", ReleasedOn = DateTime.Now.AddDays( -5 )}, new Episode {Id = 3, Name = "Episode 3", ReleasedOn = DateTime.Now.AddDays( -3 )}, new Episode {Id = 4, Name = "Episode 4", ReleasedOn = DateTime.Now.AddDays( 0 )}, }; } }Episode.cs
public class Episode { public int Id { get; set; } public string Name { get; set; } public DateTime ReleasedOn { get; set; } }Url I try to access:
http://localhost:9000/endpoints/episode
As I said, I am new to MVC so I am sure that this is something in my environment rather than the code...
Thx
davebettin
Member
313 Points
94 Posts
Re: WebApi Self Hosting Sample Error 101
Mar 19, 2012 06:29 PM|LINK
On your action method, change the return type to List<Episode> and see if that makes it happy.
@dbettin
aewilson
Member
5 Points
3 Posts
Re: WebApi Self Hosting Sample Error 101
Mar 19, 2012 07:52 PM|LINK
Thank you!