简体   繁体   中英

When I deploy the Blazor WebAssembly, API stops responding

Application = Blazor Web Assembly PWA Framework 6.0

API = Rest Api .netcore Framework 5.0

WEB Address = localtesting.mydomain.com

API Address = (localtesting.mydomain.com/api) Virtual directory.

I created virtual directory and uploaded my API in virtual directory. APi Works fine as expected

Then i try to upload Blazor WASM on root folder but when i do so API stops working. As wasm is redirecting URL.

I think its due to fallout rule from blazor which is handled by web.config

i tried to edit web.config but cant get it to work

so i am tryig to add a rule in web.config to not intercept requests for API.

未发布 Blazor WebAssembly 时的 api 响应 在 Plesk 上,这里没有人,只有 Awhen upload Blazor WebAssemblyPI 上传 Blazor WebAssembly 时

没有数据时

i have tried to edit web.config but still cant get it to work as blazor redirects all requests to wwwroot folder

Following is the web.config file

<?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="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>

    enter code here

by adding the following code in the config.Proj file

<location path="." inheritInChildApplications="false">
</location>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM