Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created September 7, 2023 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/e93d409053f471f39ffab2f9360bd71b to your computer and use it in GitHub Desktop.
Save bjoerntx/e93d409053f471f39ffab2f9360bd71b to your computer and use it in GitHub Desktop.
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddCors(p => p.AddPolicy("corsapp", builder =>
{
builder.WithOrigins("*").AllowAnyMethod().AllowAnyHeader();
}));
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) {
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseCors("corsapp");
// enable Web Sockets
app.UseWebSockets();
// adding the TX Text Control WebSocket middleware
app.UseTXWebSocketMiddleware();
// adding the viewer endpoint routing
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=TextControl}/{action}");
});
app.MapControllerRoute(
name: "default",
pattern: "{controller}/{action=Index}/{id?}");
app.MapFallbackToFile("index.html"); ;
app.Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment