James213
James213
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
lol been using chatgpt, though to be fair it did talk about profiles which I was going to try to do later, that I just found out about now.
33 replies
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
It works! dotnet run --launch-profile https
C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi>dotnet run --launch-profile https
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7045
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5206
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi
C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi>dotnet run --launch-profile https
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7045
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5206
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi
Thank you
33 replies
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
When I run with Visual Studio (not Code) I get this output. Contains 7045.
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7045
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5206
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7045
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5206
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Users\Username\source\repos\Username\InsuranceCalculator\webapi
33 replies
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
Ok, no worries. Thanks for your help anyways.
33 replies
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
No difference to dotnet run
33 replies
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
Yes, that was me just testing to see if the same ports 5206 via both methods were both being used. The problem is 7045 is not also running via cmd.
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5206"
},
"https": {
"commandName": "Project",
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7045;http://localhost:5206"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:12041",
"sslPort": 44329
}
}
}
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5206"
},
"https": {
"commandName": "Project",
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7045;http://localhost:5206"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:12041",
"sslPort": 44329
}
}
}
I'm not sure if anything is sensitive info.
33 replies
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
33 replies
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
It complains that 5206 is being used (when I do debug method) if I run dotnet run via cmd first. Otherwise, if the debug method is just running alone then it is using 5026 but is able to make the GET request which has port 7045, hence I don't see the issue being here.
33 replies
CC#
Created by James213 on 9/2/2023 in #help
✅ Frontend unable to connect to webapi when starting server manually (dotnet run)
GET https://localhost:7045/api/insurancecalculator/getCalculation/%7B%22bill%22:2000,%22billOccurrence%22:5,%22premiums%22:1000,%22cover%22:80,%22returnPA%22:10,%22duration%22:10%7D net::ERR_CONNECTION_REFUSED
GET https://localhost:7045/api/insurancecalculator/getCalculation/%7B%22bill%22:2000,%22billOccurrence%22:5,%22premiums%22:1000,%22cover%22:80,%22returnPA%22:10,%22duration%22:10%7D net::ERR_CONNECTION_REFUSED
const testResponse = await fetch('https://localhost:7045/api/insurancecalculator/getCalculation/' + JSON.stringify(extractedData)); It says 7045 but both methods of connecting to server listen on 5206 and when I try to start the server via the debugger (which works) when I have the cmd method running it complains that 5206 is being used.
33 replies
CC#
Created by James213 on 6/19/2023 in #help
❔ Unable to make a GET request
I got 200/OK. I'm guessing my python version does it automatically? As with curl, "curl sends a valid User-Agent header by default."
7 replies
CC#
Created by James213 on 6/19/2023 in #help
❔ Unable to make a GET request
I have also tried a different approach. yet the same error:
public async Task<HttpResponseMessage> GetResponse(string apiKey, string url, HttpClient client)
{
/*
Contents
1. Headers for the request
2. Return the response from the API using the HttpClient object
*/

// 1. Headers for the request
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github+json"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Headers.Add("X-GitHub-Api-Version", "2022-11-28");

// 2. Return the response from the API using the HttpClient object
HttpResponseMessage response = await client.SendAsync(request);

return response;
}
public async Task<HttpResponseMessage> GetResponse(string apiKey, string url, HttpClient client)
{
/*
Contents
1. Headers for the request
2. Return the response from the API using the HttpClient object
*/

// 1. Headers for the request
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/vnd.github+json"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Headers.Add("X-GitHub-Api-Version", "2022-11-28");

// 2. Return the response from the API using the HttpClient object
HttpResponseMessage response = await client.SendAsync(request);

return response;
}
7 replies
CC#
Created by James213 on 12/30/2022 in #help
❔ Repository not found - Git
Well, I dunno, I restarted PC logged and logged out of everything, VS code, VS, Github (then logged back in) and now it seems to work fine.
9 replies
CC#
Created by James213 on 12/30/2022 in #help
❔ Repository not found - Git
Yes, I'm actually clicking on the link and it takes me to the GitHub repository. I just set it to public from private and now get "You don't have permissions to push to "James7851/fem-manage-landing-page" on GitHub. Would you like to create a fork and push to it instead?" when I am the owner...
9 replies
CC#
Created by James213 on 11/30/2022 in #help
❔ How to pass JS object to function.
Thanks, and I also forgot to add [FromBody] to my function's parameter, GetStockDataAsync([FromBody] Stock stock).
12 replies
CC#
Created by James213 on 11/30/2022 in #help
❔ How to pass JS object to function.
Like this? Post doesn't even trigger a breakpoint, even if I have it like my original.
const testResponse = await fetch('https://localhost:5681/api/stock/getStockData/' + {
method: 'Post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
stock: formData.stock,
startDate: formData.startDate,
endDate: formData.endDate
})
});
const testResponse = await fetch('https://localhost:5681/api/stock/getStockData/' + {
method: 'Post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
stock: formData.stock,
startDate: formData.startDate,
endDate: formData.endDate
})
});
[HttpPost]
[Route("api/stock/getStockData/{formData}")]
public async Task<IActionResult> GetStockDataAsync(Stock formData){
}
[HttpPost]
[Route("api/stock/getStockData/{formData}")]
public async Task<IActionResult> GetStockDataAsync(Stock formData){
}
12 replies