No webpage was found for the web address

John chimbani 0 Reputation points

I have deployed web api to Azure. The API has an SQL server which i have configured when deploying. I have checked the connection string is in the app settings and i have migrated my database with data so it should be working, but i keep getting a 404 upon deployment even though the deployment is successful. When i check the logs, there are no internal server errors, so i assume there is nothing wrong with the code. I have added my IP add to the server to allow connections. I dont really know what else i can do. Please help. I have spent a week on this. LogsUser's image

Result User's image

Output window User's image


using System.Text;
using bokningsapp.Data; 
using bokningsapp.Entities; 
using bokningsapp.Services; 
using Microsoft.AspNetCore.Authentication.JwtBearer; 
using Microsoft.AspNetCore.Identity; 
using Microsoft.EntityFrameworkCore; 
using Microsoft.IdentityModel.Tokens; 
using Microsoft.OpenApi.Models;  

var builder = WebApplication.CreateBuilder(args);  

// DbContext builder.Services.AddDbContext<AppDbContext>(options => {     options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings:DefaultConnection").Value); });

 // Identity   builder.Services.AddIdentity<User, IdentityRole>()     .AddRoles<IdentityRole>()     .AddRoleManager<RoleManager<IdentityRole>>()     .AddEntityFrameworkStores<AppDbContext>()     .AddDefaultTokenProviders();   // Add authorization policies  builder.Services.AddAuthorization(options => {     options.AddPolicy("ElevatedRights", policy =>         policy.RequireRole(Role.Admin));     options.AddPolicy("StandardRights", policy =>         policy.RequireRole(Role.Admin, Role.User)); });   //Authentication builder.Services.AddAuthentication(options => {     options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;     options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;     options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options => {     options.SaveToken = true;     //set to true in production     options.RequireHttpsMetadata = false;      options.TokenValidationParameters = new TokenValidationParameters()     {         ValidateIssuer = true,         ValidateAudience = true,         ValidAudience = builder.Configuration.GetSection("Jwt:Audience").Value,         ValidIssuer = builder.Configuration.GetSection("Jwt:Issuer").Value,         IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration.GetSection("Jwt:Key").Value)),         ValidateActor = true,         RequireExpirationTime = true,          ValidateIssuerSigningKey = true             }; });    builder.Services.AddScoped<IAuthenticationService, AuthenticationService>();  builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at builder.Services.AddEndpointsApiExplorer();  builder.Services.AddSwaggerGen(c => {     c.SwaggerDoc("v1", new OpenApiInfo { Title = "Wedding Planner API", Version = "v1" });     c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme     {         Description = @"JWT Authorization header using the Bearer scheme. \r\n\r\n                        Enter 'Bearer' [space] and then your token in the text input below.                       \r\n\r\nExample: 'Bearer 12345abcdef'",         Name = "Authorization",         In = ParameterLocation.Header,         Type = SecuritySchemeType.ApiKey,         Scheme = "Bearer"     });     c.AddSecurityRequirement(new OpenApiSecurityRequirement()     {         {             new OpenApiSecurityScheme             {                 Reference = new OpenApiReference                 {                     Type = ReferenceType.SecurityScheme,                     Id = "Bearer"                 },                 Scheme = "oauth2",                 Name = "Bearer",                 In = ParameterLocation.Header,             },             new List<string>()         }     }); });  

// 6.
 Add CORS policy builder.Services.AddCors(options => {     options.AddPolicy("AllowAngularDevClient",         b =>         {             b                 //.WithOrigins("http://localhost:4200")                 .AllowAnyOrigin()                 .AllowAnyHeader()                 .AllowAnyMethod();         }); });   

var app = builder.Build();   

app.UseSwagger(); // 
Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) {         

app.UseSwaggerUI(); }  
//Use Cors policy 

// 3. Add seed //  
using (var scope = app.Services.CreateScope()) 
var services = scope.ServiceProvider;      await SeedManager.Seed(services);

Azure SQL Database
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
280 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,468 questions
{count} votes