ASP.NET Core RC2迁移 - 无限页面加载

时间:2016-05-27 14:48:31

标签: asp.net-core .net-core-rc2

我在将现有的 ASP.NET Core RC1 (带有angular2)应用程序迁移到RC2时遇到问题。实际问题有点奇怪。我能够修复所有编译器错误,并且iss-express开始很好。但后来没有任何反应。浏览器显示常用的加载屏幕,但开发人员工具中没有可见的网络请求。

我的Startup.cs看起来像这样:

public class Startup
{
    public Startup(IHostingEnvironment env)
    {
        var builder = new ConfigurationBuilder()
            .SetBasePath(env.ContentRootPath)
            .AddJsonFile("appsettings.json")
            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
            .AddEnvironmentVariables();
        Configuration = builder.Build();
    }

    public IConfiguration Configuration { get; set; }

    public void ConfigureServices(IServiceCollection services)
    {
        //services.AddApplicationInsightsTelemetry(Configuration);

        // Repositories
        services.AddScoped<IVendorRepository, VendorRepository>();
        services.AddScoped<IProductRepository, ProductRepository>();
        services.AddScoped<IAdjustmentRepository, AdjustmentRepository>();
        // Entityframework
        services.AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])
        );

        services.AddMvc()
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
                options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            });
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        app.UseStaticFiles();
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}"
            );
        });
    }
}

我的Program.cs看起来像这样:

public class Program
{
    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();

        host.Run();
    }
}

有没有人遇到同样的问题?如果是这样,你们是怎么解决的? 有人可以向我解释为什么web.config文件现在放在项目的根目录而不是wwwroot文件夹中?

这也是project.json gist https://gist.github.com/SamiAl90/a39d5966d2ca5ffed9dfc87ed7479680

任何帮助都将不胜感激。

0 个答案:

没有答案