Open kuldeepcis-lab opened 1 month ago
@kuldeepcis-lab thanks for contacting us.
If you register a custom middleware at the beginning of the pipeline and put a breakpoint on it, are you able to hit it when you make the API call?
app.Use((ctx,nxt) =>
{
return nxt();
});
@kuldeepcis-lab thanks for contacting us.
If you register a custom middleware at the beginning of the pipeline and put a breakpoint on it, are you able to hit it when you make the API call?
app.Use((ctx,nxt) => { return nxt(); });
I had tried it and only once breakpoint hit when application start for the first time then didn't hit the breakpoint on API Call. please see the below images :-
@kuldeepcis-lab thanks for the additional details.
Your breakpoint is in the wrong place. It should be inside the function, not at the place it's defined. (It should be on line 229).
Okay, I will put the breakpoint at line 229 and test it again.
I have tried the breakpoint inside of middleware but called only once when the application started then never hit.
@kuldeepcis-lab thanks for the additional details.
Where are you issuing the HttpClient
call from. Is it during SSR, is the app running on WebAssembly or is it Interactive Server.
@javiercn thanks for the inspection. I am using Interactive Server mode and making the HttpClient call from the Client-side razor component to get data from an API controller.
@kuldeepcis-lab thanks for the additional details.
What's the base address for your HTTP Client instance? Is the API hosted in the same server as the application?
Hi @javiercn
This is the Base address https://localhost:44328
and APIs are hosted on the same server.
@kuldeepcis-lab thanks for the additional details.
I'm going to route this to the Server folks, as this doesn't seem necessarily Blazor related.
However, I would suggest you avoid going through the indirection of calling your own server via HttpClient. Your Blazor code is already running on the server and should be able to access the services directly (in fact, it's one of the key advantages of the Server model).
By using an HttpClient + API combo you are incurring in extra unnecessary costs and potential problems like port exhaustion that you'll only discover when you deploy at scale.
Is there an existing issue for this?
Describe the bug
I'm using the .NET 8 Blazor web app template, which includes both a client and server project. In the server project, I have an API controller that I call using HttpClient. When running the application on Kestrel (using commands like dotnet run or dotnet projectassembly.dll), everything works as expected. However, when I deploy the application to either a local or remote IIS, or run it via Visual Studio on IIS, the site starts but fails after requesting the Web API controllers. It returns a 503 error for all requests, and the application becomes unresponsive with no indication of what went wrong.
Expected Behavior
The application should work smoothly and get data from database on API calls and don't shut down on refresh or Api calling.
Steps To Reproduce
Steps to reproduce the behavior:
"iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:46294", "sslPort": 44381 } },"profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } }
Exceptions (if any)
No response
.NET Version
DOTNET 8
Anything else?
For reference What I am getting on the browser please see the images.
cc: @guardrex https://github.com/dotnet/blazor-samples/issues/348