Home ASP.NET Core 2.0 Web API - cant publish on IIS
Reply: 0

ASP.NET Core 2.0 Web API - cant publish on IIS

user3205
1#
user3205 Published in May 25, 2018, 6:54 pm

I have an ASP.NET Core 2.0 WebAPI and now i want to deploy it to the IIS-Server.

In debug mode, i can make requests via postman and i get the correct results.

But when i deploy the web api to the iis-server, i cant call the web api services. So it some kind doesn't work correctly.

I have followed several guides how to do it, here is one of the guides: https://www.codeproject.com/Articles/1216729/Get-NET-Core-Web-API-Hosted-in-IIS

It still doesnt work.

ProductController.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CodeBaseFx;
using FurnitureContract.Services;
using FurnitureContract.Services.Model;
using FurnitureContract.Services.Service;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace FurnitureContract.WebApi.Controllers
{
    [Produces("application/json")]
    [Route("api/Product")]
    public class ProductController : Controller
    {
        private IProductService service = ServiceFacade.ProductService;

        public ProductController(IProductService service)
        {
            this.service = service;
        }

        [HttpGet("GetById")]
        public IEnumerable<Product> GetByProductId(string productId)
        {
            return service.GetByProductId(productId);
        }

        [HttpGet("GetByDesc")]
        public IEnumerable<Product> GetByProductDesc(string productDesc, string language)
        {
            var lng = CoreFacade.Language.GetLanguage(language);
            return service.GetByProductDesc(productDesc, lng);
            //return service.GetByProductDesc(productDesc, LanguageType.it);
        }
    }
}

Program.cs

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace FurnitureContract.WebApi
{
    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();
    }
}

I have also installed the Microsoft .NET Core Windows Server Hosting Bundle File on the IIS Server

Here my Deployment steps:

  1. I have published my project to a folder and then copied it to the webserver on the target folder.
  2. Ive created an application pool with no managed code setting.
  3. Then ive created a new application and selected the application pool above and set the physical path to the web api folder.

When i try to make a request via postman, i dont get any result.

Can anyone help?

Thanks

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.368056 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO