2 messaggi dal 29 aprile 2021
in locale va tutto bene funziona

a quando cerco di pubblicato su IIS nel url vedo che ritorna un errore "%2FError%3F"

L'esempio è quello del CaoncatManagee link https://docs.microsoft.com/it-it/aspnet/core/security/authorization/secure-data?view=aspnetcore-5.0

lanchSetting

{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:58352/",
"sslPort": 44305
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "Identity/Account/Login?ReturnUrl=%2F",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ContactManager": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "Identity/Account/Login?ReturnUrl=%2F",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:8001;http://localhost:8000"
},
"WSL 2": {
"commandName": "WSL2",
"launchBrowser": true,
"launchUrl": "https://localhost:8001/Identity/Account/Login?ReturnUrl=%2F",
"environmentVariables": {
"ASPNETCORE_URLS": "https://localhost:8001;http://localhost:8000",
"ASPNETCORE_ENVIRONMENT": "Development"
},
"distributionName": ""
}
}
}

program.cs
using ContactManager.Data;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;

namespace ContactManager
{
#region snippet
public class Program
{
public static void Main(string[] args)
{
//origine
var host = CreateHostBuilder(args).Build();


/*
var host = new HostBuilder()
.ConfigureAppConfiguration((hostContext, builder) =>
{
// Add other providers for JSON, etc.

if (hostContext.HostingEnvironment.IsDevelopment())
{
builder.AddUserSecrets<Program>();
}
})
.Build();

*/



using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;

try
{
//var context = services.GetRequiredService<ApplicationDbContext>();
//context.Database.Migrate();

// requires using Microsoft.Extensions.Configuration;
//Riga commentata
var config = host.Services.GetRequiredService<IConfiguration>();
//Riga commentata

// Set password with the Secret Manager tool.
// dotnet user-secrets set SeedUserPW <pw>
//Riga commentata
var testUserPw = config["SeedUserPW"];

Console.WriteLine(services);
Console.WriteLine(testUserPw);

SeedData.Initialize(services, testUserPw).Wait();
//Riga commentata
}
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occurred seeding the DB.");
}
}

Console.WriteLine("test uno bis ");
Console.WriteLine("test due bis");
Console.WriteLine("test tre bis");
host.Run();


}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});

/*
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();

webBuilder.UseUrls("http://localhost:8000/","https://localhost:8001");

});

*/
}


#endregion
}
Startup.cs

using ContactManager.Authorization;
using ContactManager.Data;
using Microsoft.AspNetCore.Authentication.Certificate;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;


namespace ContactManager
{
public class Startup
{


public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

#region snippet_defaultPolicy
#region snippet
#region snippet2
public void ConfigureServices(IServiceCollection services)
{

services.AddAuthentication(
CertificateAuthenticationDefaults.AuthenticationScheme)
.AddCertificate()
// Adding an ICertificateValidationCache results in certificate auth caching the results.
// The default implementation uses a memory cache.
.AddCertificateCache();



services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));

services.AddDefaultIdentity<IdentityUser>(
options => options.SignIn.RequireConfirmedAccount = true)
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();
#endregion

services.AddRazorPages();

services.AddAuthorization(options =>
{
options.FallbackPolicy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
});
#endregion

// Authorization handlers.
services.AddScoped<IAuthorizationHandler,
ContactIsOwnerAuthorizationHandler>();

services.AddSingleton<IAuthorizationHandler,
ContactAdministratorsAuthorizationHandler>();

services.AddSingleton<IAuthorizationHandler,
ContactManagerAuthorizationHandler>();




}
#endregion

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

// Set up configuration sources.
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);


if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/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.UseAuthentication();
app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthentication();
app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
}
}
82 messaggi dal 19 ottobre 2005
dev.to
Domanda banale senza aver analizzato il codice che hai postato: IIS è configurato per far funzionare le applicazioni ASP.NET Core? Sai che devi installare un modulo su IIS per far funzionare le applicazioni ASP.NET Core, vero?

Ciao!
2 messaggi dal 29 aprile 2021
ok sono un po nuovo in questo lato server
ho la seguente macchina equipaggiata
ver 10
Hai un link e una procedura per farlo?
dove vedo i moduli installati come lo distinguo i moduli da installare ?

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.