That error does not come from your API code directly.
It usualy means browser stopped the request before it could give jQuery response.
Common causes:
CORS issue → API not allowing requets from your domain.
Network/URL issue → wrong URL, DNS issue, HTTPS mismatch (calling HTTP from HTTPS).
Response format issue → API returned invalid or unexpected content (like plain content('0')) instead of JSON/XML/text that your jQuery expects.
Why might you still see TypeError: Failed to fetch?
Not really hitting your handler
If your page is /ControllName/ForgotPassword, then the URL should be:
/ControllName/ForgotPassword?handler=ForgotPwd&UserName=xxx
not just /?handler=....
CORS or HTTPS mismatch
If you’re calling this from another domain (or from HTTPS → HTTP), the browser blocks it.
In that case, “Failed to fetch” shows before it even gets the response.
You can check program.cs file both configuration.
Exception on server
If the server throws inside OnGetForgotPwdAsync, the API may return 500 Internal Server Error.
Check Network tab in DevTools (F12) → what’s the actual status code?
If your page is a Razor Page at /ForgotPwd, then:
const resp = await fetch(`/ForgotPwd?handler=ForgotPwd&UserName=${usrname}`);
If you always want text back:
return Content("0", "text/plain");
Open Network tab → click the request → check:
Status code (200? 404? 500?)
Response body (is it really 0?)
Most likely issue = wrong URL (/?handler=...) or server error.