Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local deployment IIS with alias #158

Open
carlosxjose opened this issue Nov 13, 2024 · 0 comments
Open

Local deployment IIS with alias #158

carlosxjose opened this issue Nov 13, 2024 · 0 comments

Comments

@carlosxjose
Copy link

I tested v2 and works fine on IIS local deployment with Alias, but in v3 I received these errors only on local IIS:

Exception

System.FormatException: The format of value '<null>' is invalid.
   at System.Net.Http.Headers.HttpHeaderParser.ParseValue(String value, Object storeValue, Int32& index)
   at System.Net.Http.Headers.AuthenticationHeaderValue.Parse(String input)
   at Serilog.Ui.Web.Authorization.Filters.BasicAuthenticationFilter.AuthorizeAsync()
   at Serilog.Ui.Web.Authorization.AuthorizationFilterService.CanAccessAsync()
   at Serilog.Ui.Web.Authorization.AuthorizationFilterService.CheckAccessAsync(Func`1 onSuccess, Func`1 onFailure)
   at Serilog.Ui.Web.Endpoints.SerilogUiAppRoutesDecorator.GetHomeAsync()
   at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()

Properties

<properties><property key='ConnectionId'>18230571306091327259</property><property key='TraceIdentifier'>8000af1c-0003-fd00-b63f-84710c7967bb</property><property key='EventId'><structure type=''><property key='Id'>2</property><property key='Name'>ApplicationError</property></structure></property><property key='SourceContext'>Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer</property><property key='RequestId'>8000af1c-0003-fd00-b63f-84710c7967bb</property><property key='RequestPath'>/eCFMPS/serilog-ui/</property></properties>

I've tested these codes, commented lines are for v2.0;

// Services
            services.AddSerilogUi(options => options
                //.AddScopedBasicAuthFilter()
                .AddScopedAuthorizeLocalRequestsAuthFilter()
                .AddScopedBasicAuthFilter()                
                .UseSqlServer(opts => opts
                .WithConnectionString(Misc.Helpers.ConfigurationSectionValue(configuration, "Serilog:WriteTo", "Args:connectionString")!)
                .WithTable(Misc.Helpers.ConfigurationSectionValue(configuration, "Serilog:WriteTo", "Args:sinkOptionsSection:tableName")!)));

    app.UseSerilogUi(options =>
    {
    //    v2.0
    //    //options.Authorization.Filters =
    //    //[
    //    //    new BasicAuthenticationFilter { UserName = "mpssa", Password = "12qwasZX" }
    //    //];

    //    //options.Authorization.RunAuthorizationFilterOnAppRoutes = true;
        var PathBase = "eCFMPS";

        //if (!string.IsNullOrWhiteSpace(PathBase))
        //{
        //    //options.WithHomeUrl(PathBase);
        //    options.WithRoutePrefix(PathBase);
        //}

        options.EnableAuthorizationOnAppRoutes();
        options.WithExpandedDropdownsByDefault();
        options.HideSerilogUiBrand();       
        options.WithAuthenticationType(Serilog.Ui.Web.Models.AuthenticationType.Basic);
    });

On debug mode it works fine but on deployment (Release mode) with an Alias like http://localhost/ecfMPS it failed... I try PathBase option as swell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant