Reputation: 75
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
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