ASP.NET Core constant requests to home controller - model-view-controller

I have an ASP.NET Core MVC application hosted on Google Compute Engine, and when I check the logs, it seems that www.mysite.com/home/index is constantly being requested even though I am not searching that URL in my browser and nobody else knows the actual URL. Why is this? I am concerned that it may be interfering with some of my processes.
I am running the app on Windows Server 2016 and I often Remote Desktop into it. Could either of these be the reason behind the logs I am getting?
{"#t":"2019-01-01T09:37:24.4301536Z","#m":"Request starting HTTP/1.1 GET http://10.142.0.4/ ","#i":"ca22a1cb","Protocol":"HTTP/1.1","Method":"GET","ContentType":null,"ContentLength":null,"Scheme":"http","Host":"10.142.0.4","PathBase":"","Path":"/","QueryString":"","HostingRequestStartingLog":"Request starting HTTP/1.1 GET http://10.142.0.4/ ","EventId":{"Id":1},"SourceContext":"Microsoft.AspNetCore.Hosting.Internal.WebHost","RequestId":"0HLJFPIU5NJ9V:00000001","RequestPath":"/","CorrelationId":null,"ConnectionId":"0HLJFPIU5NJ9V"}
{"#t":"2019-01-01T09:37:24.5299320Z","#m":"Route matched with \"{action = \\\"Index\\\", controller = \\\"Home\\\"}\". Executing action \"TelebotApplication.Controllers.HomeController.Index (TelebotApplication)\"","#i":"a44c0341","RouteData":"{action = \"Index\", controller = \"Home\"}","ActionName":"TelebotApplication.Controllers.HomeController.Index (TelebotApplication)","EventId":{"Id":1},"SourceContext":"Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker","ActionId":"dc996f72-2933-4b90-9a5e-ccbfe11d91ba","RequestId":"0HLJFPIU5NJ9V:00000001","RequestPath":"/","CorrelationId":null,"ConnectionId":"0HLJFPIU5NJ9V"}
{"#t":"2019-01-01T09:37:24.5405482Z","#m":"Executing action method \"TelebotApplication.Controllers.HomeController.Index (TelebotApplication)\" - Validation state: Valid","#i":"dad538d7","ActionName":"TelebotApplication.Controllers.HomeController.Index (TelebotApplication)","ValidationState":"Valid","EventId":{"Id":1},"SourceContext":"Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker","ActionId":"dc996f72-2933-4b90-9a5e-ccbfe11d91ba","RequestId":"0HLJFPIU5NJ9V:00000001","RequestPath":"/","CorrelationId":null,"ConnectionId":"0HLJFPIU5NJ9V"}
{"#t":"2019-01-01T09:37:24.5441766Z","#m":"Executed action method \"TelebotApplication.Controllers.HomeController.Index (TelebotApplication)\", returned result \"Microsoft.AspNetCore.Mvc.ViewResult\" in 0.4835ms.","#i":"50a9e262","ActionName":"TelebotApplication.Controllers.HomeController.Index (TelebotApplication)","ActionResult":"Microsoft.AspNetCore.Mvc.ViewResult","ElapsedMilliseconds":0.48350000000000004,"EventId":{"Id":2},"SourceContext":"Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker","ActionId":"dc996f72-2933-4b90-9a5e-ccbfe11d91ba","RequestId":"0HLJFPIU5NJ9V:00000001","RequestPath":"/","CorrelationId":null,"ConnectionId":"0HLJFPIU5NJ9V"}
This seems to pretty much repeat itself endlessly.
Thanks

when I check the logs, it seems that www.mysite.com/home/index is constantly being requested even though I am not searching that URL in my browser and nobody else knows the actual URL
For this issue, it is caused by Health checking you configured in the GCP.
The issue I am facing, is occassionally, public static void
Main(string[] args) is re-entered without my instruction.
For this issue, it is usually caused by the application recycling. Exceptions in request would not make application recycling.

Related

.NET Core 5 GET Action Called Twice

Environment
.NET Core 5 Web Application
IIS 10
Azure VM
Issue
Executing a GET action results in that action being called a second time. The first call shows cookie information. The second does not show cookie information.
What we've tried:
Occurs for GET requests but not POST requests
Occurs without a view (NOT a javascript issue)
Browser does not show two requests. This occurs server-side.
Does not occur in Firefox Privacy Mode
Does not occur on localhost. Only in production.
Occurs with HTTPS off
Fork of the solution does not exhibit this behavior (makes middleware unlikely cause)
Best guesses:
.NET 5 (deprecated) or dependencies (a bad developer blames his tools)
IIS Settings
Session
Code example:
Controller
// no other filters
[HttpGet]
public IActionResult DupeRequestTest()
{
// database insert with Dapper
var sql = #"INSERT INTO TrackingTable
(CookieJson, CreateDate)
VALUES(#CookieJson, GETDATE());";
using var con = new SqlConnection(_connectionString);
con.Open();
con.Execute(sql, new
{
CookieJson=JsonConvert.SerializeObject(Request.Cookies),
});
// returning a status code so no View, javascript, or other requests
return StatusCode(200);
}
Database results:
CookieJson
CreateDate
[{"Key":"SessionId","Value":"ac6f292c-1ca1-5179-9123-78a04d382dea"}]
2022-10-25 09:46:30.523
[]
2022-10-25 09:46:30.770
Thank you. Any help, such as next testing steps, would be appreciated - short of building a new app.
I'm sure the answer is either very stupid or very hidden.

Blazor app not running server code when on hosted server

I have a blazor web assembly app and I have 3 projects that were created. The client, server and shared. I assume all of these are deployed as standard when using the webdeploy?
The site works in that it displays the pages etc. However when I go to a page that contacts the server project via the Http.PostAsJsonAsync() method, I get the blazor error page (which I setup to say "oops").
Obviously I get no details as to what is going wrong. So I have no idea what is happening. Is the server app compiled into the Web assembly app? If so why would it not be running the server code? Plus I suppose the other question is how do I get it to report the error so that I can get an idea as to what is going wrong?
It works absolutely fine when running it through Visual Studio.
This is the first time I have deployed to a hosted server so there is a very high chance I have done something wrong...
The method I am calling literally does nothing other than returning a 200 message. So I assume the issue is with calling the server method itself.
Firstly, use Logging:
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/logging?view=aspnetcore-5.0&pivots=server
#inject ILogger<MyComponent> Logger
Then wrap your Http.PostAsJsonAsync() call in a Try Catch block.
Log the error in the Catch block:
try
{
await Http.PostAsJsonAsync()
}
catch (Exception e)
{
Logger.LogError(e);
}
After deployment, edit your web.config file:
<aspNetCore processPath="dotnet"
arguments=".\Hospitillity.App.Server.dll"
stdoutLogEnabled="true" // <<< MAKE THIS true
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess">
Note, the setting stdoutLogEnabled="true". This will cause your hosting provider to generate log files.
Then recycle your app pool on your hosting provider.
Connect to your website again, and after the error you should have some more details about error logged in
\logs\stdout_nnnnnnnnnnnnnn_nnnnnn.log
on the hosting server.
Take it from there ...

Http Post - long delay at state ExecuteRequestHandler

I have an asp.net mvc website hosted on Windows Server 2012r2 Standard which uses KnockoutJS to display data in a grid. This server is dedicated to the process that I'm having trouble with - it does not server any other requests.
An ajax call is made to a "GetRecords" action of a controller. This returns data for a couple of dozen records very quickly.
The user is able to make amendments to the data and submit for update. The knockout code makes another ajax call, this time posting the records. At this point the site "hangs" for a long time (over 10 minutes), but it does complete successfully and the updated date is persisted to a database. During the "hang time" the CPU for the IIS Worker Processes hovers around the 50% mark.
I'm trying to figure out what's causing the delay. It seems that the delay happens before the first line of code of the controller action is reached. I've added trace statements to the action and I can see that once the 1st line is executed, then the action completes within a couple of seconds.
From the IIS manager, I've drilled in to "Worker Processes"\"Current Requests" during the time the page is "hung", I can see that the State is listed as "ExecuteRequestHandler" and the Module Name is "ManagedPipelineHandler". There are no other "Current Requests" displayed.
Using the Chrome dev tools, I've captured the json being posted for the update, it is approx 4mb in size.
I've ruled out the problem being caused by bandwidth because I've tested from a browser running locally (on the web server), and I get the same delay.
Also, when I post the same number of records on the same site hosted on my dev VM then it works fine - completes end-to-end in under 3 seconds.
Any suggestion on steps I can take to improve performance of the post?
I have created a process dump of the IIS worker process when it is in the "hanging" state, this is available at: onedrive link
It seems that "Thread 28" is causing the issue, since this has a "Time spent in user mode" value of over 2 minutes. I requested the process dump about 2 minutes after making the http post request from the website. The post did eventually complete ok after about 20 minutes
Able to work around this problem bypassing the MVC model binding. The view model param (editBatchVm) that was passed into the controller method has been replaced. So, instead of:
public void ResubmitRejectedVouchersAsNewBatch(EditBatchViewModel editBatchVm)
{
I now have:
public void ResubmitRejectedVouchersAsNewBatch()
{
string requestData = "";
using (var reader = new StreamReader(Request.InputStream))
{
requestData = reader.ReadToEnd();
}
EditBatchViewModel editBatchVm = JsonConvert.DeserializeObject<EditBatchViewModel>(requestData);

Vaadin session expired immediately

I have a simple vaadin application created from an achetype. The page with button is loaded but when you click it, session is already expired. This problem occurs just only under this conditions:
session is https
browsert is IE 11.0.14393.0 (after Windows 10 Aniversary Update 1607)
SPNEGO is used
Server is WildFly 10.1.0.Final
Other browsers (EDGE, Firefox, Chrome) works fine. Before Aniversary update the IE 11 worked as well.
I know it is not enough information but I don't know what can be important. Can you point me what should I check / should I do?
I haven't find anything strange at logs and communication. I'm guessing there will be something wrong with a session but I can not find what is bad :-(
The problem is caused by the internally generated request for favicon. This request is generated internally by IE and uses wrong session ID (jsessionID). Server creates a new session and answers with its ID. Unfortunately the IE then uses this new session ID for other requests. Other browsers (and previous IE version) correctly use the original jsessionID and do not the one that is returned as a response to the internally generated favicon request.
Solution: I have changed the favicon links within my application and pointed them outside of the secured server area.
#Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
// FIX for IE11 at Windows 10 after anniversary update
response.getDocument().head().getElementsByAttributeValue("rel", "shortcut icon").attr("href", "/static/favicon.ico");
response.getDocument().head().getElementsByAttributeValue("rel", "icon").attr("href", "/static/favicon.ico");
}

Can anyone make grizzly-websockets-chat work under standalone grizzly?

I'm struggling to run grizzly-websockets-chat. I've successfully compiled the sample. HttpServer.createSimpleServer is running and serving a test index.html on localhost:8080. WebSocketEngine.getEngine().register("/chat", chatApplication) executes without complaint. However, localhost:8080/chat returns "Resource identified by path '/chat', does not exist.". This is not under Glassfish - just standalone Grizzly/2.2.19.
Comments in some places suggest that websocket support is off by default - I'm unable to determine how to turn it on outside of Glassfish. I have only the test index.html in docroot.. is anything else required?
I'm not running anything special on the client side - no js, nothing. I've not seen any such thing in the sample. Surprisingly, I've not found a good doc or running example. Maybe is a user problem? ;/
Looks like websocket code may be being invoked:
$ java -jar ./tyrus-client-cli-1.1.jar ws://localhost:8080/chat
# Connecting to ws://localhost:8080/chat...
# Failed to connect to ws://localhost:8080/chat due to Handshake error
Any help much appreciated!
Change your request URI to ws://localhost:8080/grizzly-websockets-chat/chat.
The ChatApplication has the following defined for isApplicationRequest():
#Override
public boolean isApplicationRequest(HttpRequestPacket request) {
return "/grizzly-websockets-chat/chat".equals(request.getRequestURI());
}

Resources