ограничение загрузки размера файла в ASP.NET MVC: больше чем 1 maxRequestLength, устанавливающий в web.config (s)

Вот очень простой пример:

import logging
l = logging.getLogger("test")

# Add a file logger
f = logging.FileHandler("test.log")
l.addHandler(f)

# Add a stream logger
s = logging.StreamHandler()
l.addHandler(s)

# Send a test message to both -- critical will always log
l.critical("test msg")

Вывод будет отображать «test msg» на stdout, а также в файле.

17
задан Zhaph - Ben Duguid 25 June 2009 в 22:34
поделиться

2 ответа

См. Мой ответ здесь: ASP.NET MVC и httpRuntime executionTimeout

11
ответ дан 30 November 2019 в 13:34
поделиться

I believe the Path attribute shouldn't start or end with a "/" - so you should have:

<location path="File">
  <system.web>
    <httpRuntime executionTimeout="60" maxRequestLength="4096" />
  </system.web>
</location>
<location path="Picture">
  <system.web>
    <httpRuntime executionTimeout="60" maxRequestLength="1024" />
  </system.web>
</location>

Your virtual or physical directory–level Web.config's shouldn't have the elements.

That should sort you out.

The docs for the Location element even have this very example:

The following code example demonstrates how to set the uploaded file size limit to 128 KB for only the page specified.

<configuration>
  <location path="UploadPage.aspx">
    <system.web>
      <httpRuntime maxRequestLength="128"/>
    </system.web>
  </location>
</configuration>
11
ответ дан 30 November 2019 в 13:34
поделиться
Другие вопросы по тегам:

Похожие вопросы: