Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to deploy Angular2 application built using AspNetCore in IIS

$
0
0

I am facing some issues in deploying the Angular2 application built using AspNetCore in IIS.

I tried publishing the application using 'Publish' wizard in Visual Studio IDE. Copied the entire published contents and placed in the physical path mapped to a Virtual directory in IIS.

when I try to browse the Index.html page I am getting the following error "HTTP Error 404.0 - Not Found" as specified in the snapshot. Please find the virtual folder path structure in the snapshot.

Any ideas what is the mistake I am doing here and what is the correct way to deploy aspnetcore application in IIS?enter image description hereimage

My Startup.cs file is as below

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">
public class Startup
    {
        public Startup(IHostingEnvironment env)
        {
            // Set up configuration sources.
            var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }

        public IConfigurationRoot Configuration { get; set; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

        }

        // 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.Run(ctx =>
            {
                ctx.Response.Redirect("/index.html");
                return Task.FromResult(0);
            });
        }
    }
<div class="snippet-result"><div class="snippet-ctas"><button type="button"></button></div></div></div></div>

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>