Ved Test
Ved Test

Reputation: 75

How to Publish ASP.NET Core WEB API Project on Local IIS in Visual Studio 2017 Community RC?

I want to publish ASP.NET Core WebAPI Project with swagger on IIS. i want to run the Project on local machine with IP Address.

Configuration of My PC is: Visual Studio 2017 Community RC Windows 10 IIS

Please help me.

Upvotes: 1

Views: 2799

Answers (1)

Denis Staforkin
Denis Staforkin

Reputation: 21

Have you tried "this one (learn.microsoft.com)"? It helped for me. Don't forget to configure authentication and access to your site physical path for application pool identity you are going to use.

UPD (reply to comment): In case you're using Swashbuckle.AspNetCore package you can try somethig like this in your ConfigureServices(IServiceCollection services):

// Register the Swagger generator, defining one or more Swagger documents
services.AddSwaggerGen(c =>
{
    var info = new Info
    {
        Title = "My web API",
        Version = "v1.0",
        Contact = new Contact()
        {
            Email = "[email protected]",
            Name = "Denis",
            Url = "https://stackoverflow.com"
        },
        Description = "My API"
    };
    c.SwaggerDoc("v1.0", info);
    var basePath = AppContext.BaseDirectory; // this is not equal to wwwroot folder due to WebHostBuilder settings
    var xmlPath = Path.Combine(basePath, "MyApi.xml");
    c.IncludeXmlComments(xmlPath);
});

And in Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory):

// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();

// Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("/swagger/v1.0/swagger.json", "My web API v1.0");
    c.EnableDeepLinking();
});

Upvotes: 2

Related Questions