Blazor WASM-在IIS上的独立部署

时间:2020-10-26 21:10:32

标签: iis blazor blazor-webassembly

我正在按照here的说明尝试在IIS上部署Blazor WASM应用程序。

  • 这只是Blazor WASM应用程序的现成示例
  • 我已将应用发布到文件夹中
  • 我已将URL重写模块添加到IIS
  • 我已经为IIS添加了动态压缩支持
  • 我在默认网站上创建了一个新的Web应用程序,并将其指向发布Blazor应用程序的文件夹

调用该应用程序将生成一个页面,其中包含“发生了未处理的错误。请重新加载”。

查看浏览器开发工具中的请求,将从wwwroot文件夹中感染index.html,这表明url重写规则正在触发,但是对css / bootstrap.min.css,_framework / blazor.webassembly的请求.js和css / app.css都失败,状态为404-找不到。

我想念什么?

Windows 10 2004。

1 个答案:

答案 0 :(得分:1)

尝试在index.html文件中设置基本路径:

@Metadata(
   mv = {1, 4, 0},
   bv = {1, 0, 3},
   k = 1,
   d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b6\u0018\u00002\u00020\u0001:\u0002\u0003\u0004B\u0007\b\u0002¢\u0006\u0002\u0010\u0002\u0082\u0001\u0002\u0005\u0006¨\u0006\u0007"},
   d2 = {"LRepoSearchResult;", "", "()V", "Error", "Success", "LRepoSearchResult$Success;", "LRepoSearchResult$Error;", "test_kotlin"}
)
public abstract class RepoSearchResult {
   private RepoSearchResult() {
   }

   // $FF: synthetic method
   public RepoSearchResult(DefaultConstructorMarker $constructor_marker) {
      this();
   }

   @Metadata(
      mv = {1, 4, 0},
      bv = {1, 0, 3},
      k = 1,
      d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\b\u0086\b\u0018\u00002\u00020\u0001B\u0013\u0012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003¢\u0006\u0002\u0010\u0005J\u000f\u0010\b\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003HÆ\u0003J\u0019\u0010\t\u001a\u00020\u00002\u000e\b\u0002\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003HÆ\u0001J\u0013\u0010\n\u001a\u00020\u000b2\b\u0010\f\u001a\u0004\u0018\u00010\rHÖ\u0003J\t\u0010\u000e\u001a\u00020\u000fHÖ\u0001J\t\u0010\u0010\u001a\u00020\u0004HÖ\u0001R\u0017\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007¨\u0006\u0011"},
      d2 = {"LRepoSearchResult$Success;", "LRepoSearchResult;", "data", "", "", "(Ljava/util/List;)V", "getData", "()Ljava/util/List;", "component1", "copy", "equals", "", "other", "", "hashCode", "", "toString", "test_kotlin"}
   )
   public static final class Success extends RepoSearchResult {
      @NotNull
      private final List data;

      @NotNull
      public final List getData() {
         return this.data;
      }

      public Success(@NotNull List data) {
         Intrinsics.checkParameterIsNotNull(data, "data");
         super((DefaultConstructorMarker)null);
         this.data = data;
      }

      @NotNull
      public final List component1() {
         return this.data;
      }

      @NotNull
      public final RepoSearchResult.Success copy(@NotNull List data) {
         Intrinsics.checkParameterIsNotNull(data, "data");
         return new RepoSearchResult.Success(data);
      }

      // $FF: synthetic method
      public static RepoSearchResult.Success copy$default(RepoSearchResult.Success var0, List var1, int var2, Object var3) {
         if ((var2 & 1) != 0) {
            var1 = var0.data;
         }

         return var0.copy(var1);
      }

      @NotNull
      public String toString() {
         return "Success(data=" + this.data + ")";
      }

      public int hashCode() {
         List var10000 = this.data;
         return var10000 != null ? var10000.hashCode() : 0;
      }

      public boolean equals(@Nullable Object var1) {
         if (this != var1) {
            if (var1 instanceof RepoSearchResult.Success) {
               RepoSearchResult.Success var2 = (RepoSearchResult.Success)var1;
               if (Intrinsics.areEqual(this.data, var2.data)) {
                  return true;
               }
            }

            return false;
         } else {
            return true;
         }
      }
   }

   @Metadata(
      mv = {1, 4, 0},
      bv = {1, 0, 3},
      k = 1,
      d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0000\b\u0086\b\u0018\u00002\u00020\u0001B\u0011\u0012\n\u0010\u0002\u001a\u00060\u0003j\u0002`\u0004¢\u0006\u0002\u0010\u0005J\r\u0010\b\u001a\u00060\u0003j\u0002`\u0004HÆ\u0003J\u0017\u0010\t\u001a\u00020\u00002\f\b\u0002\u0010\u0002\u001a\u00060\u0003j\u0002`\u0004HÆ\u0001J\u0013\u0010\n\u001a\u00020\u000b2\b\u0010\f\u001a\u0004\u0018\u00010\rHÖ\u0003J\t\u0010\u000e\u001a\u00020\u000fHÖ\u0001J\t\u0010\u0010\u001a\u00020\u0011HÖ\u0001R\u0015\u0010\u0002\u001a\u00060\u0003j\u0002`\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0006\u0010\u0007¨\u0006\u0012"},
      d2 = {"LRepoSearchResult$Error;", "LRepoSearchResult;", "error", "Ljava/lang/Exception;", "Lkotlin/Exception;", "(Ljava/lang/Exception;)V", "getError", "()Ljava/lang/Exception;", "component1", "copy", "equals", "", "other", "", "hashCode", "", "toString", "", "test_kotlin"}
   )
   public static final class Error extends RepoSearchResult {
      @NotNull
      private final Exception error;

      @NotNull
      public final Exception getError() {
         return this.error;
      }

      public Error(@NotNull Exception error) {
         Intrinsics.checkParameterIsNotNull(error, "error");
         super((DefaultConstructorMarker)null);
         this.error = error;
      }

      @NotNull
      public final Exception component1() {
         return this.error;
      }

      @NotNull
      public final RepoSearchResult.Error copy(@NotNull Exception error) {
         Intrinsics.checkParameterIsNotNull(error, "error");
         return new RepoSearchResult.Error(error);
      }

      // $FF: synthetic method
      public static RepoSearchResult.Error copy$default(RepoSearchResult.Error var0, Exception var1, int var2, Object var3) {
         if ((var2 & 1) != 0) {
            var1 = var0.error;
         }

         return var0.copy(var1);
      }

      @NotNull
      public String toString() {
         return "Error(error=" + this.error + ")";
      }

      public int hashCode() {
         Exception var10000 = this.error;
         return var10000 != null ? var10000.hashCode() : 0;
      }

      public boolean equals(@Nullable Object var1) {
         if (this != var1) {
            if (var1 instanceof RepoSearchResult.Error) {
               RepoSearchResult.Error var2 = (RepoSearchResult.Error)var1;
               if (Intrinsics.areEqual(this.error, var2.error)) {
                  return true;
               }
            }

            return false;
         } else {
            return true;
         }
      }
   }
}

以下是iis应用程序文件夹路径:

enter image description here

您可以将其设置为发布文件夹。

web.conifg文件:

<base href="/CoolApp/">

索引文件:

enter image description here

输出:

enter image description here

注意:确保将iis_iusrs和iusr权限分配给站点文件夹。

https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/?view=aspnetcore-3.1&tabs=visual-studio