小编Tho*_*ann的帖子

C# 中字符串插值内的字符串插值导致编译器错误

以下 C# 表达式会导致我的程序出现编译器错误:

$"Getting image from {location.IsLatitudeLongitude ? $"{location.Latitude} - {location.Longitude}" : location.Location}."
Run Code Online (Sandbox Code Playgroud)

难道不能像这样使用字符串插值吗?或者根本不可能做到这一点?

c# csc string-interpolation

7
推荐指数
1
解决办法
2616
查看次数

ASP.NET Core 授权重定向到错误的 URL

我正在尝试运行映射了以下路由的 Web 应用程序:

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                "default",
                "WoL/{controller=Account}/{action=Login}/{id?}");
        });
Run Code Online (Sandbox Code Playgroud)

如果用户未通过身份验证并尝试访问具有 AuthorizeAttribute 的操作,则应将用户重定向到默认登录 URL(如上所示)。但是用户被重定向到“/Account/Login”而不是“/WoL/Account/Login”。如果用户未通过身份验证,如何将用户重定向到“/WoL/Account/Login”?我已经配置了以下 Cookie 身份验证:

        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            LoginPath = new PathString("/WoL/Account/Login"),
            AutomaticChallenge = true
        });
Run Code Online (Sandbox Code Playgroud)

redirect routes asp.net-core-mvc .net-core asp.net-core

5
推荐指数
2
解决办法
5290
查看次数

实体框架核心过滤器 DbSet

在 Entity Framework Core 中是否可以自动过滤DbSet<TEntity>a DbContext?我正在寻找为 EntityFrameworkCore实现类似的东西。我想IQueryable<TEntity>在通过DbSet<TEntity>.

.net c# entity-framework asp.net-core

4
推荐指数
1
解决办法
8824
查看次数