小编Seb*_*n A的帖子

如何将IdentityServer4与带有ClientCredentials ASP.NET Core的Javascript客户端一起使用

我正在实现IdentityServer4,我正在制作3个不同的proyects:

所有项目都是使用ASP.NET Core创建的,但JS Client使用静态文件.

我需要JS Client只使用身份令牌(不是访问令牌)与API连接,因为我只需要访问API,我不需要管理用户身份验证.

我正在阅读快速入门帖子https://identityserver4.readthedocs.io/en/dev/quickstarts/1_client_credentials.html

在我阅读时,我认为我需要使用Implicit Grand Type,我不需要OpenID Connect,只需要OAuth2.

另外我读了这篇文章 https://identityserver4.readthedocs.io/en/dev/quickstarts/7_javascript_client.html 但他们使用访问令牌,我不需要它,连接到我正在使用的API oidc-client-js库https ://github.com/IdentityModel/oidc-client-js和我搜索使用Implicit Grand Type的方式,但我使用的方法将我重定向到http:// localhost:5000/connect/authorize页面(I认为这是我需要使用OpenID Connect的时候)

实现这一目标的最佳方法是什么?我错了什么?如何使用api进行认证并调用http:// localhost:5001/values

IdentityServer项目

Config.cs

public static IEnumerable<Client> GetClients()
        {
            return new List<Client>
            {
                new Client
                {
                    ClientId = "client",
                    ClientName = "JavaScript Client",
                    // no interactive user, use the clientid/secret for authentication
                    AllowedGrantTypes = GrantTypes.Implicit,
                    AllowAccessTokensViaBrowser = true,



                    RedirectUris = new List<string> …
Run Code Online (Sandbox Code Playgroud)

javascript c# oauth-2.0 asp.net-core-1.0 identityserver4

11
推荐指数
1
解决办法
4784
查看次数

如何修复响应式DataTable的最后一列

我有一个数据表,最后一列是两个按钮.我正在实现响应式数据表,但我需要最后一列(列"Opciones")不被隐藏,并且总是显示无论其他列.

如果您需要更多信息,请告诉我.

在此输入图像描述

HTML(ASP.NET视图)

@model PagedList.IPagedList<VinculoSC.ReservaDeCabanasWeb.Models.Reserva>
@using PagedList.Mvc;

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout2.cshtml";
}


<div id="content">
    <div>
        <div class="row">
            <div id="divAlertReserva" role="alert"></div>
        </div>
    </div>
    <table class="table" id="listaSolicitudes" width="100%">
        <thead>
            <tr>
                <th>
                    Cabaña
                </th>
                <th>
                    Empresa
                </th>
                <th>
                    Cédula
                </th>
                <th>
                    Nombres
                </th>
                <th>
                    Apellidos
                </th>
                <th>
                    Email
                </th>
                <th>
                    Fecha inicial
                </th>
                <th>
                    Fecha final
                </th>
                <th>
                    Opciones
                </th>
            </tr>
        </thead>

        <tbody></tbody>

    </table>

</div>
<div id="openModal" class="modalDialog">
    <div>
        <a href="#close" title="Close" class="close" onclick="CancelOperation()">X</a>
        <h2>Por favor anexe una descripción al …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery datatables

5
推荐指数
1
解决办法
4371
查看次数

'System.Web.Mvc.SelectListItem'不包含名为'id'#2的属性

我有以下实体:

public class Entidad
{
    [Key]
    public int Id { get; set; }
    public string Nombre { get; set; }

    public virtual ICollection<Propiedad> Propiedades { get; set; }
}

public class Propiedad
{
    [Key]
    public int Id { get; set; }

    public virtual Entidad Entidad { get; set; }

    public string Codigo { get; set; }
    public string Nombre { get; set; }
    public string TipoDeDatos { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我有这个控制器动作

public ActionResult Create()
{
    ViewBag.Entidad = new SelectList(db.Entidades); …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc entity-framework razor

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

林克之间的表现

我正在使用Entity Framework,我想知道以下代码之间是否有任何区别.第一个和第二个代码似乎通过Entidad.Nombre =="Empresa"过滤掉所有项目,最后一个代码似乎只获得Entidad.Nombre =="Empresa"的项目.我错了吗?什么是更好的?

var listFields = from b in unitOfWork.PropiedadRepository.Get()
                         where b.Entidad.Nombre == "Empresa"
                         select b;
var listFields2 = unitOfWork.PropiedadRepository.Get().Where(x => x.Entidad.Nombre == "Empresa");
var listFields3 = unitOfWork.PropiedadRepository.Get(x => x.Entidad.Nombre == "Empresa");
Run Code Online (Sandbox Code Playgroud)

这是GenericRepository类.所有存储库都继承了它.

public sealed class GenericRepository<TEntity> where TEntity : class
{
    private readonly ConfigurationDbDataContext _context;
    private readonly DbSet<TEntity> _dbSet;

    public GenericRepository(ConfigurationDbDataContext context)
    {
        _context = context;
        _dbSet = context.Set<TEntity>();
    }

    public IEnumerable<TEntity> Get(
        Expression<Func<TEntity, bool>> filter = null,
        Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
        string includeProperties = "")
    { …
Run Code Online (Sandbox Code Playgroud)

.net c# linq entity-framework

3
推荐指数
1
解决办法
330
查看次数

在linq中除以零例外

我有以下代码,它提出除零异常.我如何纠正并改进代码?

List<RelacionEjecucionPendientes> iniciativasEjecucionPendienteses = actividades
.GroupBy(cl => cl.iniciativaName)
.Select(cl => new RelacionEjecucionPendientes
{
    Nombre = cl.Key,
    ATiempoEjecucionCantidad = cl.Count(c => c.estado != "No Iniciada" && (Convert.ToDateTime(c.fechaVencimiento).Day - actualTime.Day) >= 0),
    ATiempoEjecucionPorcentaje = String.Format("{0:0}", 
        (cl.Count(c => c.estado != "No Iniciada" && (Convert.ToDateTime(c.fechaVencimiento).Day - actualTime.Day) >= 0) /
         cl.Count(c => c.estado != "No Iniciada") != 0 ? cl.Count(c => c.estado != "No Iniciada") : 1))
}).ToList();
Run Code Online (Sandbox Code Playgroud)

c# linq

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