Angular不适用于配置了SPA的Asp网络核心

时间:2018-10-17 15:33:37

标签: angular asp-net-core-spa-services

我有一个带有SPA的ASP .NET Core项目,该项目设置为使用Angular6。这是我的启动文件。我删除了其他服务以使其易于查看。

public void ConfigureServices(IServiceCollection services)
    {

        services.AddSpaStaticFiles(options => options.RootPath = "JwtClientApp/dist");

                  services.AddMvc();
    }
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {

        app.UseStaticFiles();

        app.UseSpaStaticFiles();

        app.UseMvc(routes =>
        {
            routes.MapRoute(name: "default", template: "{controller}/{action=Index}/{id}");
        });
        app.UseSpa(options =>
        {
            options.Options.SourcePath = "JwtClientApp";
            if (env.IsDevelopment())
            {
                options.UseAngularCliServer(npmScript: "start");
            }
        });
    }

我的JwtClientApp文件夹与根文件夹位于同一级别。我已经从launchSettings中删除了launchUrl,并且使用IIS Express。 启动应用程序时出现此错误:Uncaught ReferenceError:在runtime.js,polyfills.js,styles.js,vendor.js和main.js中未定义值。当我查看文件夹中的那些文件时,其代码确定,但是当我使用浏览器查看它们时,我只会看到文本值。 enter image description here

0 个答案:

没有答案