My Project
Loading...
Searching...
No Matches
Program.cs File Reference

Functions

builder.Services. AddControllers ()
 
builder.Services. AddEndpointsApiExplorer ()
 
builder.Services. AddSwaggerGen (c=> { c.AddServer(new OpenApiServer { Url="http://localhost:8083", Description="Production Server" });var xmlCommentsFile=$"{Assembly.GetExecutingAssembly().GetName().Name}.xml";var xmlCommentsFullPath=Path.Combine(AppContext.BaseDirectory, xmlCommentsFile);c.IncludeXmlComments(xmlCommentsFullPath);})
 
builder.Services. AddSwaggerExamplesFromAssemblies (Assembly.GetEntryAssembly())
 
builder.Services. AddDbContext< ApplicationDbContext > (options=> { options.UseSqlServer(builder.Configuration.GetConnectionString("CodePulseConnectionString"));})
 
builder.Services. AddScoped< ICategoryRepository, CategoryRepository > ()
 
builder.Services. AddScoped< IBlogPostRepository, BlogPostRepository > ()
 
 if (app.Environment.IsDevelopment())
 
app. Use (async(context, next)=> { await next();if(context.Response.StatusCode==404 &&!System.IO.Path.HasExtension(context.Request.Path.Value)) { context.Request.Path="/index.html";await next();} })
 
app. UseDefaultFiles ()
 
app. UseSwagger ()
 
app. UseSwaggerUI ()
 
app. UseStaticFiles ()
 
app. UseHttpsRedirection ()
 
app. UseCors (options=> { options.AllowAnyHeader();options.AllowAnyOrigin();options.AllowAnyMethod();})
 
app. UseAuthorization ()
 
app. MapControllers ()
 
app. Run ()
 

Variables

var builder = WebApplication.CreateBuilder(args)
 
var app = builder.Build()
 

Function Documentation

◆ AddControllers()

builder.Services. AddControllers ( )

◆ AddDbContext< ApplicationDbContext >()

builder.Services. AddDbContext< ApplicationDbContext > ( options ,
{ options.UseSqlServer(builder.Configuration.GetConnectionString("CodePulseConnectionString"));}  )

◆ AddEndpointsApiExplorer()

builder.Services. AddEndpointsApiExplorer ( )

◆ AddScoped< IBlogPostRepository, BlogPostRepository >()

builder.Services. AddScoped< IBlogPostRepository, BlogPostRepository > ( )

◆ AddScoped< ICategoryRepository, CategoryRepository >()

builder.Services. AddScoped< ICategoryRepository, CategoryRepository > ( )

◆ AddSwaggerExamplesFromAssemblies()

builder.Services. AddSwaggerExamplesFromAssemblies ( Assembly. GetEntryAssembly())

◆ AddSwaggerGen()

builder.Services. AddSwaggerGen ( c ,
{ c.AddServer(new OpenApiServer { Url="http://localhost:8083", Description="Production Server" });var xmlCommentsFile=$"{Assembly.GetExecutingAssembly().GetName().Name}.xml";var xmlCommentsFullPath=Path.Combine(AppContext.BaseDirectory, xmlCommentsFile);c.IncludeXmlComments(xmlCommentsFullPath);}  )

◆ if()

if ( app.Environment.IsDevelopment() )

◆ MapControllers()

app. MapControllers ( )

◆ Run()

app. Run ( )

◆ Use()

app. Use ( async(context, next) ,
{ await next();if(context.Response.StatusCode==404 &&!System.IO.Path.HasExtension(context.Request.Path.Value)) { context.Request.Path="/index.html";await next();} }  )

◆ UseAuthorization()

app. UseAuthorization ( )

◆ UseCors()

app. UseCors ( options ,
{ options.AllowAnyHeader();options.AllowAnyOrigin();options.AllowAnyMethod();}  )

◆ UseDefaultFiles()

app. UseDefaultFiles ( )

◆ UseHttpsRedirection()

app. UseHttpsRedirection ( )

◆ UseStaticFiles()

app. UseStaticFiles ( )

◆ UseSwagger()

app. UseSwagger ( )

◆ UseSwaggerUI()

app. UseSwaggerUI ( )

Variable Documentation

◆ app

var app = builder.Build()

◆ builder

var builder = WebApplication.CreateBuilder(args)