Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Sanjeev M
    @zeus82
    How do I tell ASP where I want the root of my app to be? I want to the root page to be at 'localhost/app' so that all my razor pages will continue to work
    Jesper Hansen
    @jespersh
    @zeus82
    app.UseEndpoints(endpoints =>
      endpoints.MapRazorPages();
      endpoints.MapControllers();
      endpoints.MapFallbackToFile("/app/{**slug}", "app/index.html");
      endpoints.MapFallbackToFile("{**slug}", "index.html");
    }
    Sanjeev M
    @zeus82
    thanks @jespersh, but whats ''**slug"?
    Jesper Hansen
    @jespersh
    @zeus82 like if you have endpoints.Map("api/{**slug}", HandleApiFallback);
            private Task HandleApiFallback(HttpContext context)
            {
                string slug = context.Request.RouteValues["slug"].ToString();
                context.Response.StatusCode = StatusCodes.Status404NotFound;
                return Task.FromResult(0);
            }
    if I visit localhost/api/bacon then slug is bacon
    you can use it for logging pages that doesn't seem to exist anymore
    Sanjeev M
    @zeus82
    ahh - I see - cool - thanks!
    Jesper Hansen
    @jespersh
    @zeus82 :thumbsup:
    L Suarez
    @lsuarez5280
    I have a question about the Microsoft.OpenApi lib. Since the models in that library provide a description of the API, is it possible to use that description for model validation in MVC to generate 400 responses?
    It's a lot more capable in terms of describing the kinds of responses I'd like to accept.
    Than say data annotations.
    L Suarez
    @lsuarez5280
    I guess my question is more like "is that functionality already out there somewhere?"
    Meai1
    @Meai1
    how do I add aspnetcore 5 preview to an existing project?
    Jesper Hansen
    @jespersh
    @Meai1 looking to upgrade to 5 or install it?
    TeBeCo
    @tebeco
    he tried to installed the package name Microsoft.AspNetCore that's all
    full answer on dotnet/cli gitter
    also the original question was nasty and blaming msft for an invalid command since 3.x
    that's not very nice (also the issue is that you want to read about FrameworkReference)

    here was the original msg :

    dotnet add myproject.csproj package Microsoft.AspNetCore -v 5.0.0-preview.5.* ---> "Unable to find package Microsoft.AspNetCore with version (>= 5.0.0-preview.5)"
    WHY
    nuget is still a complete joke of a tool
    .net 5 should not be allowed to come out until you fix the horribleness of nuget

    Jesper Hansen
    @jespersh
    Wish people could be friendlier to each other. Guess the world is just that kind of stressful place now
    TeBeCo
    @tebeco
    a recap of the answer:
    • please don't be angry at people when looking for help because it might be your fault to begin with (that's why you are looking for help)
    • You are trying to add a package
    • The source of package truth is nuget.org
    • here is the page of that package https://nuget.org/packages/Microsoft.AspNetCore
    • This package does not exists anymore
    • this change was made with aspnetcore 3.0
    • aspnetcore 3.0 was released 2019-09-23
    • So this means the CLI works properly, it's just your cmd that is invalid as you are trying to add something not existing
    • You are probably looking for either a FrameworkReference or an Sdk
    so @Meai1 are you interested about understanding what changed in 3.0 ? and why the thing you are trying to do, just cannot work because it does not exists anymore ?
    I can't force you to read docs about it so just ping us here if it does interest you so that we could look for docs about it for you to read
    (hope it helps)
    Jesper Hansen
    @jespersh
    @tebeco since the aspnetcore isn't defined as a package in *.csproj, but just <Project Sdk="Microsoft.NET.Sdk.Web">, do you just update TargetFramework to NET5 and it uses aspnetcore5?
    I only recently created my first aspnetcore project and didn't notice this until now
    ghendo
    @ghendo
    Hi there. Regrading .net core 2.2 authentication. I am storing roles data separately from the users store as I am using AWS cognito. I need to add the Roles for a user to the User on login. This does not seem to work in the login page but does work on the Index page. Even after sign in and confirmed signed in there is no capital U user. Would this be because the Login page in not authenticated(obviously) and the claims principle is not created until the first authenticated page is hit? or some other weird reason.
    TeBeCo
    @tebeco
    @jespersh only if you are doing a Host
    the Microsoft.NET.Sdk.Web is not the true fix, it's a way bigger change, if fact that SDK is doing a FrameworkReference under the hood
    also using this Microsoft.NET.Sdk.WebSDK will tell the compiler that you are not doing a ClassLib but a "Web" project (hence the Web Sdk)
    last but not least, since 3.0, AspNetCore is not netstandard anymore, it only target netcore runtime
    there's various answer to that issue depending on what you are doing
    • An app ? => change SDK to Microsoft.NET.Sdk.Web
    • A classlib only for netcoreapp 3.x or 5.x ? => make sure to target netcoreapp3.x or net5.0 + add <FrameworkReference Include="Microsoft.AspNetCore.App" />
    • A classlib for 3.x AND ALSO need backward compat for 2,x and maybe need netstandard ? => multiple TargetFramework + Condition on <ItemGroup>
    TeBeCo
    @tebeco
    (trying to find a better formatted article)
    cross target support will make it look like this :
    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
      </PropertyGroup>
    
      <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
        <FrameworkReference Include="Microsoft.AspNetCore.App" />
      </ItemGroup>
    
      <ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp3.0'">
        <PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.1.3" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.1.3" />
        <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
      </ItemGroup>
    
    </Project>
    (from Adrew blog)
    that's what i meant for @Meai1 to be whilling to read about it :D it's a very simple choice that she/he'll have to do because we have 0 context here, but then it's VERY easy to fix
    Jesper Hansen
    @jespersh
    @tebeco aha. TIL. Thanks for explaining
    Meai1
    @Meai1
    no it's not okay at all that a library is some kind of weird "SDK" or "FrameworkReference"
    Michał Zegan
    @webczat
    sdk is not a library. FrameworkReference refers to a shared framework/library.
    also dotnet core bcl is one too
    Meai1
    @Meai1
    it should be a library
    Michał Zegan
    @webczat
    and so it is.
    Jesper Hansen
    @jespersh
    Michał Zegan
    @webczat
    yes it does
    Jesper Hansen
    @jespersh
    @Meai1 I suppose you're free to just use Microsoft.NET.Sdk and unfold that Sdk.props into it?
    Meai1
    @Meai1
    I'm not going to do that obviously, I created an issue so they can fix this complicated nonsense. They already created a hugely complicated system called nuget and now they cant even put an http server into it. That's totally unacceptable
    Jesper Hansen
    @jespersh
    why would you put a http server into nuget.exe?
    Michał Zegan
    @webczat
    what? hrmm what do you want to achieve? a plain http server without rest of aspnetcore?
    Tim Seaward
    @Drawaes
    take a look at bedrock if you want a raw http server