Bad Request for URL containing token route on server
I have this endpoint:
[HttpGet("setup-account/{token}")]
public IActionResult SetupAccountPassword([FromRoute] string token, [FromQuery] string email)
{
//manually decode because route parameters do not get automatically decoded.
token = Base64UrlEncoder.Decode(token);
return View("ResetPassword", new ResetPasswordViewModel(email, token));
}
I open it from an email link such as:
https://localhost:5001/auth/setup-account/Q2ZESjhDT3ZWdEtLK0FSSHBaV09tNG5Lem1wTXpWcjF0MmV5ZWF5Z1ZYZkNsS3licVBFV3k5VlFOc2I2VEN5TmF5anNLV0hyck15eEpNb21zMis1cG9UME1FUkw4V2hwWFVXRVlWcnkrNlhzYUoyK0QwcW1mdzNJUHNERlFaR3FjRWxzQ2loamVBTEpTM1ZLWHROaTVDd2l0djRGTGdvc013SHFOMWQveFBLREVoNDNGQ3pPV1plcXlEa2ZydjBWRjkyNjl3PT0?email=test@icloud.com
this link works properly on localhost but it doesn't once I publish the website to a server and access it from the domain, in that case I get 400 Bad Request error Invalid URL
any idea?
34 Replies
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
thanks for the reply, this is hosted in IIS, I'm not sure where exactly I can increase the log level there. Log files aren't showing any errors also.
appsettings.json should work i think
changing the LogLevel didn't seem to affect it as I got no files/updated from IIS
looking into this I found: https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/health-diagnostic-performance/troubleshoot-http-400-errors-in-iis
where I got
HTTP/2.0 GET /auth/setup-account/Q2ZESjhMTEJMczNqZHVCRG1DMEZEYXV5RCtxVjRtanZSL2YxdkUvVFQyZ3BxUmhaV2tQa2FVMmgwOGxCRWtWUzB4ZlZ3Q2dRSjdTTnlSMmJ6eGM1empIQ1BsTkhVbk80SzNoTmNHZHpsTnMvUDVROVJqd3MwWnNHVEdmeXMydVRRb0FQb2VTbmhFOGR5TFZQNDg5bUxubEJIR2pZbjVPdU5SMk9lMzVhRlBwQ2ZnMTdpRjFoWjloSjBaa01DcUllREhaT3lBPT0?email=test@example.com 1 400 - URL -
and that URL part is described here: https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/aspnet/site-behavior-performance/error-logging-http-apis#kinds-of-errors-that-the-http-api-logs
URL --> A parse error occurred while processing a URL
I'm still not sure what could be causing it since email and token are both strings
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Plerx
appsettings.json should work i think
Quoted by
<@689473681302224947> from #Bad Request for URL containing token route on server (click here)
React with ❌ to remove this embed.
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
changed log level to Debug for appsettings.json (including production and development) but there's no changes in that page, same error as before
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
I'm thinking the error should be more descriptive, but it doesn't change at all.
neither are there any logs generated, or I just can't find them.
The http response only changes if u enable dev exceptions on your application builder
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
that's the web.config but there's no logs folder within the website path
and the appsettings.json:
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
created those in wwwroot/applicationName > log folder > stdout folder
restarted website, tried the same endpoint/url, no other files generate in there
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
yes that's windows
it should be in inetpub then?
path seems relative in webconfig ./
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
no that's inetpub > wwwroot dir
not the application's wwwroot obviously
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
huh, well that's where the new website is also
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
C: / intepub has got a few folders:
ftproot,
history,
logs,
wwwroot
wwwroot has all the websites there
meanwhile the logs folder had no stdout in it.
I added stdout there also but no logs yet
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
yep I understand, they threw me on this issue and it's already been setup like this!
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
made a new path C:/iis-websites/website1 and deployed there. webconfig had
added C:/iis-websites/website1/logs/stdout folder
also on C:/logs/stdout
tried with stdoutLogEnabled = false and true while requesting that page/url and no files there
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
yep tried with true also, nothing changed..
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
no luck still! am I supposed to add something in program.cs maybe
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
finally fixed it!
I ran out of options, the error in httperr as mentioned above was simply URL and not about the length. but i figured what the hell nothing else makes sense.
so I added registry key UrlSegmentMaxLength as mentioned here: https://stackoverflow.com/questions/42243211/increase-max-url-length-in-asp-net-core
there was no need for the webconfig section to be added
it required a system restart for it to take effect but works perfectly now, thanks for helping guys