I’m having an odd problem while developing a .NET 6 web app on Azure. In the app, we use a traditional MVC model (i.e., not Razor Pages). For the purpose of testing, we created a sample “TestingController” that we’re going to delete before moving to production (I understand that this is maybe not the ideal testing method, but this is an internal app and everything is pretty tightly integrated).
Anyway, this TestingController
has an action method, Documents()
, that takes a handler from the services, an id
route parameter, and a docid
. I was testing the code triggered by this endpoint when I noticed some odd behaviour. Whenever I go to enter the route it my browser by typing /
after the base URL, it autocompletes as expected. However, as soon as the route autocompletes it will call the controller action. Keep in mind, this is before I hit Enter or send any requests. Meaning, by the time I do hit Enter, it will be sending the request for the second time. It only happens the first time it autocompletes, and apparently only right after launching the app. It happens consistently but it’s hard to reproduce in other scenarios. It doesn’t appear to be happening to the other routes from what I can tell.
The first time this happened to me, I thought that maybe it was probing the route or something along those lines, maybe for controller discovery or some internal .NET black box that I don’t know about, and somehow it just triggered the breakpoint. But, I can confirm that it is executing the code, because if I put a “Hello, World”, for example, it will print to the console.
Oddly enough, this has happened to me in a different app before, and to this day have not found a suitable answer. The only commonalities I can think of is that both of the autocompleted URLs have query parameters in them. This happens in multiple browsers (I haven’t tried Firefox though). I took a video of it happening but I cannot share it since it has some company information in it.
My best guess was Browser Link in Visual Studio, but I turned that off and it still happens. The only other thing I can think of is, in Chromium-based browsers, when you type in the search bar (the “Omnibox”), it makes two calls to internal SQLLite databases to get the history information. However, I don’t think that would do any preliminary calls to the server or anything. At first I thought it was prefetching the page before you send the request or something to save load time, but that’s just random conjecture. My colleague suggested response caching, but in the same vein, I don’t know if that would make a call directly to the server, I don’t know though. The other methods in the controller have an [HttpGet]
with the template
(route) string, the one that’s triggering twice has the [HttpGet]
only, could that affect anything?
Any idea what could be causing this mysterious behaviour? I obviously don’t want code executing just by typing in URL and not sending the request…