In a Web-Application, written in C# in .NET Core 3.1, i want to Display a Datatable of all the Blobs in one of our Company's Azure Blob Storages. For this i'm using Datatables.net in the Frontend with Ajax-Calls which target a selfwritten API in the same Web-App. The API should get all the searched Blobs, format them for easier viewing and then give them back to the Table. Locally it really works like a charm. However, soon after deployment i noticed that the Ajax-Call just simply returns a 404 Response.
For reference:
My API-Controller
[Route("Blob/api/[controller]")]
[ApiController]
public class BlobsController : ControllerBase
{
private readonly string _connectionString;
private readonly string _container;
private readonly BlobContainerClient _client;
public BlobsController(IConfiguration configuration)
{
IEnumerable<IConfigurationSection> _blobStorageSection = configuration.GetSection("BlobStorage").GetChildren();
_connectionString = _blobStorageSection.Single(e => e.Key == "ConnectionString").Value;
_container = _blobStorageSection.Single(e => e.Key == "ContainerName").Value;
_client = new BlobContainerClient(_connectionString, _container);
}
[HttpGet("{EncodedDelimiter}/{EncodedPrefix}")]
public ActionResult GetBlobs(string EncodedDelimiter, string EncodedPrefix)
{
if (! StorageIsAvailable())
return NotFound();
string Delimiter = WebUtility.UrlDecode(EncodedDelimiter);
string Prefix = WebUtility.UrlDecode(EncodedPrefix);
Pageable<BlobHierarchyItem> BlobHierarchy = _client.GetBlobsByHierarchy(delimiter: Delimiter, prefix: Prefix);
return Ok(EnrichBlobList(BlobHierarchy));
}
[HttpGet("init/{EncodedDelimiter}")]
public ActionResult Initialize(string EncodedDelimiter)
{
if (! StorageIsAvailable())
return NotFound();
string Delimiter = WebUtility.UrlDecode(EncodedDelimiter);
Pageable<BlobHierarchyItem> BlobHierarchy = _client.GetBlobsByHierarchy(delimiter: Delimiter);
return Ok(EnrichBlobList(BlobHierarchy));
}
Here the Ajax-Call Snippet
var Table = $("#BlobTable").DataTable({
ajax:{
url: "api/Blobs/init/%2F",
dataSrc: ""
},
processing: true,
columnDefs:[
{
"targets": 0,
"data": "standartizedName",
},
{
"targets": 1,
"data": null,
"render": function(full){
return renderTyp(full);
},
"width": "10%"
},
{
"targets": 2,
"data": null,
"render": function(full){
return renderDatum(full);
},
"width": "15%"
},
{
"targets": 3,
"data": null,
"render": function(full){
return renderAction(full);
},
"orderable": false,
"searchable": false,
"width": "10%"
}
],
order:[[1, "desc"]],
pageLength: 50
});
And bc i have seen similar Problems where the Source-Problem was in StartUp:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<TestDbcontext>(options => options.UseSqlServer(Configuration.GetConnectionString("TestDB"),
sqlServerOptionsAction: sqlOptions =>
{
sqlOptions.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromMinutes(5),
errorNumbersToAdd: null
);
}));
if (Env.IsDevelopment())
{
UseFakeAuthenticationAndAuthorization(services);
//UseAuthenticationAndAuthorization(services, Configuration);
}
else
{
//UseFakeAuthenticationAndAuthorization(services);
UseAuthenticationAndAuthorization(services, Configuration);
}
services.AddControllersWithViews();
RepositoriesTestGUI(services);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// 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.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Home}/{id?}");
});
}
Has someone else an Idea what could be the Problem? An API-Call is an absolute Necessity since the Storage contains 70k Files
EDIT:
By Request here are the Network Details
Bc this is my first Post i can't put embedded Pictures in apparently