0

I ran into an issue with signalR's js client in which when using the token factory, the token is sent in the query string. When our .net 8 application was deployed to azure, if the token exceeded ~2100 characters, we would get a 404 during initial connection. After some research, I found the likely culprit was iis's request filtering module. I found adding

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxQueryString="5000"></requestLimits>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

I feel quite silly as I have not had to change any of the webserver limits since working with aspnetcore. Our project does not have a web.config at the moment; however, when published the generated one contains

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\Web.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

Editing this in a test environment to have

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\Web.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
      <security>
        <requestFiltering>
          <requestLimits maxQueryString="5000"></requestLimits>
        </requestFiltering>
      </security>
    </system.webServer>
  </location>
</configuration>

resolved the issue.

What is the correct way to resolve this? A web config in the project with

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\Web.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
      <security>
        <requestFiltering>
          <requestLimits maxQueryString="5000"></requestLimits>
        </requestFiltering>
      </security>
    </system.webServer>
  </location>
</configuration>

or just

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxQueryString="5000"></requestLimits>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

Thanks!

1 Answer 1

0

Ya reading literally https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/web-config?view=aspnetcore-8.0 answered my question in about two seconds...sorry just haven't worked with it in a loooong time and just wanted to make sure I wouldn't mess something up and have iis serve files it shouldn't.

From the docs linked:

If a web.config file is present in the project, the file is transformed with the correct processPath and arguments to configure the ASP.NET Core Module and moved to published output. The transformation doesn't modify IIS configuration settings in the file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.