RickStrahl / Westwind.AspnetCore.LiveReload

ASP.NET Core Live Reload Middleware that monitors file changes in your project and automatically reloads the browser's active page
Other
473 stars 42 forks source link

Visual Studio for MAC #12

Closed wickedw closed 5 years ago

wickedw commented 5 years ago

Hi Rick,

Thanks for the middleware :) just trying it out on Mac OSX via VS4 Mac, I have added the appropriate nuget and additions to ConfigureServices and Configure, but when I start up the site (Razor pages in asp net core 2.2), I do not see any of your infected javascript (and therefore no reload) in the page header.

How could I debug what I am missing?

Thanks for your help Matt

wickedw commented 5 years ago

As usual, as soon as I posted, I changed -

     services.AddLiveReload(config =>
            {
                // optional - use config instead
                //config.LiveReloadEnabled = true;
                //config.FolderToMonitor = Path.GetFullname(Path.Combine(Env.ContentRootPath,"..")) ;
            });

Which I had just cut and pasted in, to this -

services.AddLiveReload();

And it started working (and I can see the reload code just before end body tag).

I don't think this was really the issue as switched it back again and still seemed to work? but thought would post all is OK, and close it.

RickStrahl commented 5 years ago

Hmmm... that should work either way, whether empty or with the passed in config object, unless you had some incorrect configuration values in there. With everything commented out in the code block the behavior should be identical.

RickStrahl commented 5 years ago

Just to be sure I hooked this up with the code you have above (ie. with the config all commented out but included) and for me this works without issue. Can you clarify if you had everything commented out or whether you had made changes to the config values that might not have been valid?

Thanks.

wickedw commented 5 years ago

Hi Rick,

I did not have a config file, and that's what I thought when originally posting, but nothing was happening (I was also looking in the wrong place for the injection code, assumed header for no reason, which did not help), so I tried it again just now with the config variant and it "works".

I have noticed this in the trace

Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLPAR8PFAH8T", Request id "0HLPAR8PFAH8T:00000001": An unhandled exception was thrown by the application.
System.Net.WebSockets.WebSocketException (0x80004005): The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseReceived, CloseSent'
   at System.Net.WebSockets.WebSocketValidate.ThrowIfInvalidState(WebSocketState currentState, Boolean isDisposed, WebSocketState[] validStates)
   at System.Net.WebSockets.ManagedWebSocket.CloseAsync(WebSocketCloseStatus closeStatus, String statusDescription, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at Westwind.AspNetCore.LiveReload.LiveReloadMiddleware.WebSocketWaitLoop(WebSocket webSocket)
   at Westwind.AspNetCore.LiveReload.LiveReloadMiddleware.HandleWebSocketRequest(HttpContext context)
   at Westwind.AspNetCore.LiveReload.LiveReloadMiddleware.InvokeAsync(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 14586.2548ms 101 
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/__livereload  

But it seems to work fine.

Put it down to coder error, maybe I had something missing at the time, or needed to clean build or something.