Bad Request - Invalid URL (v2021)

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
lfernandes
User
Posts: 77

Bad Request - Invalid URL (v2021)

Post by lfernandes »

We are using File Upload to Folder. However, we found that the download links for files generated by ASPNETMAKER have shown an error, Bad Request - Invalid URL
HTTP Error 400. The request URL is invalid. Apparently this error occurs for files with names longer than 100 characters and/or that have many special character references.

Are there any limitations for this feature? How to solve ?

It is noteworthy that when we rename the files the code generated by ASPNETMAKER works normally.


MichaelG
User
Posts: 1111

Post by MichaelG »

Please make sure that you are using utf-8 project (HTML -> Charset = "utf-8") and the file name consists of utf-8 characters. Alternatively, show a problem file name.


lfernandes
User
Posts: 77

Post by lfernandes »

yes, we are using utf-8 project (HTML -> Charset = "utf-8"). Example of the filename causing the error:
CONTRATO PARCERIA POLO SÃO JOÃO DA PONTE-MG_Ctt_Parceria_SÃO JOÃO DA PONTE - MG_YDUQS - SANTA_CATARINA_.pdf


MichaelG
User
Posts: 1111

Post by MichaelG »

You may need to increase the maxAllowedContentLength / maxUrl / maxQueryString in web.config. For example:

	<security>
		<requestFiltering>
			<requestLimits maxAllowedContentLength="..." maxUrl="..." maxQueryString="..." />
		</requestFiltering>
	</security>

lfernandes
User
Posts: 77

Post by lfernandes »

In ASPNETMAKER in tools - advanced settings - option "encrypt file path" when disabling and regenerating the project the file url works.

So I conclude that the problem is related to the file path encryption functionality.

In which part of the ASPNETMAKER code can we check the logic of this functionality?


MichaelG
User
Posts: 1111

Post by MichaelG »

With encrypted file path, the URL will become a very long string, so that still points to the same problem per my previous reply .

You may need to increase the maxAllowedContentLength / maxUrl / maxQueryString in web.config.


lfernandes
User
Posts: 77

Post by lfernandes »

The suggested solution did not solve the problem


MichaelG
User
Posts: 1111

Post by MichaelG »

Show your changes.


lfernandes
User
Posts: 77

Post by lfernandes »

Michael,
the problem was worked around by applying the following configuration in the web config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.web>
<httpRuntime maxQueryStringLength="32768" maxUrlLength="65536" />
</system.web>
<system.webServer>
<handlers>
<add name="aspNetCore" path="" verb="" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\AspNetMaker2021.dll" requestTimeout="00:02:00" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess"></aspNetCore>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="52428800" maxQueryString="32768" maxUrl="65536" />
</requestFiltering>
</security>
</system.webServer>


darkdragon
User
Posts: 150

Post by darkdragon »

If you use IIS, there is a limit from http.sys
Check the docs: https://docs.microsoft.com/en-us/troubl ... ry-windows


Post Reply