Blazor WASM在使用HTTPS协议在iis上发布后显示错误403

pxyaymoc  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(130)

我的Blazor WASM .net5项目在IIS 10上发布后无法工作。它在控制台中显示了很多错误,几乎所有的dll都抛出403错误,还有一些其他的错误说在尝试验证完整性时发生了未知错误我不知道这是与blazor有关还是与iis有关。我唯一发现的就是

<BlazorEnableCompression>false</BlazorEnableCompression>

加入Blazor项目,但是Bud不起作用现在我不知道从哪里开始寻找解决方案。有什么想法吗?
谢谢你

更新

我使用发布窗口,依赖框架作为部署模式,浏览器作为目标运行时

qcbq4gxm

qcbq4gxm1#

iis网站文件夹中应该有一个web.config文件

看起来像这样:注意重写规则。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <remove fileExtension=".blat" />
      <remove fileExtension=".dat" />
      <remove fileExtension=".dll" />
      <remove fileExtension=".json" />
      <remove fileExtension=".wasm" />
      <remove fileExtension=".woff" />
      <remove fileExtension=".woff2" />
      <mimeMap fileExtension=".blat" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".dll" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".dat" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".json" mimeType="application/json" />
      <mimeMap fileExtension=".wasm" mimeType="application/wasm" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
    </staticContent>
    <httpCompression>
      <dynamicTypes>
        <add mimeType="application/octet-stream" enabled="true" />
        <add mimeType="application/wasm" enabled="true" />
      </dynamicTypes>
    </httpCompression>
    <rewrite>
      <rules>
        <rule name="CanonicalHost_HTPPS_Rule1" stopProcessing="true">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_HOST}" pattern="^alpha-clean\.gr$" negate="true" />
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
          <action type="Redirect" url="https://alpha-clean.gr/{R:1}" />
        </rule>
        <rule name="LowerCaseRule1" stopProcessing="true">
          <match url="[A-Z]" ignoreCase="false" />
          <action type="Redirect" url="{ToLower:{URL}}" />
        </rule>
        <rule name="Serve subdir">
          <match url=".*" />
          <action type="Rewrite" url="wwwroot\{R:0}" />
        </rule>
        <rule name="SPA fallback routing" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
          <action type="Rewrite" url="wwwroot\" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

如果希望文件随项目沿着发布,请确保将以下内容添加到项目文件中:<PublishIISAssets>true</PublishIISAssets>

相关问题