小编Lui*_*cia的帖子

如何使用Ajax Begin表单正确使用部分视图

我在index.cshtml中有以下代码

@using Kendo.Mvc.UI;
@using xx.Relacionamiento.Modelo.Bussiness.Entities;
@using xx.Relacionamiento.Modelo.Bussiness.Entities.Custom;

<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

@model PresupuestosGenerale

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

    }

<div class="">

    <div id="ContenedorPresupuestoGeneral">
        @Html.Partial("CreateOrEditPresupuestoGeneralxx", Model)
    </div>
    <br />
    <br />
Run Code Online (Sandbox Code Playgroud)

然后我有以下PartialView

@using xx.Relacionamiento.Modelo.Bussiness.Entities.Enumeraciones;
@using xx.Relacionamiento.Modelo.Bussiness.Entities;
@using Kendo.Mvc.UI;


@model PresupuestosGenerale
<div class="panel panel-default">
    <div class="panel-heading">
        @using (Ajax.BeginForm("CreateOrEditPresupuestoGeneralxx", new AjaxOptions() { HttpMethod = "Post", UpdateTargetId = "ContenedorPresupuestoGeneral", InsertionMode = InsertionMode.Replace }))
        {
            @Html.HiddenFor(h => h.PresupuestoGeneralId)
            @Html.Hidden("Categoria",CategoriaEvento.xx.ToString())
            <div class="row">
                <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                    <label>Presupuesto Global xx</label>
                    <br /> …
Run Code Online (Sandbox Code Playgroud)

c# ajax asp.net-mvc asp.net-mvc-4 kendo-ui

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

如何将 DI 与 Microsoft Graph 结合使用

我有一个 .net web api 核心项目,我将调用 microsoft graph

所以我创建了一个配置类:

public class GraphConfiguration
    {
        public static void Configure(IServiceCollection services, IConfiguration configuration)
        {
            //Look at appsettings.Development.json | https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.1
            var graphConfig = new AppSettingsSection();
            configuration.GetSection("AzureAD").Bind(graphConfig);

            IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                .Create(graphConfig.ClientId)
                .WithTenantId(graphConfig.TenantId)
                .WithClientSecret(graphConfig.ClientSecret)
                .Build();
                
            ClientCredentialProvider authenticationProvider = new ClientCredentialProvider(confidentialClientApplication);
            GraphServiceClient graphServiceClient = new GraphServiceClient(authenticationProvider);     

        }
    }
Run Code Online (Sandbox Code Playgroud)

在我的控制器中我有这个:

 public class UserController : ControllerBase
    {
        private TelemetryClient telemetry;
        private readonly ICosmosStore<Partner> _partnerCosmosStore;
        private readonly GraphServiceClient _graphServiceClient;


        // Use constructor injection to get a TelemetryClient instance.
        public UserController(TelemetryClient …
Run Code Online (Sandbox Code Playgroud)

.net c# dependency-injection asp.net-web-api2 asp.net-core

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

Magento的价格范围

默认情况下,Magento中的分层导航会在price属性中显示

从0到1000
从1001到2000
等等

是否可以通过配置或代码更改此设置?如果必须通过代码,请提供代码示例以及我需要修改的文件.

magento layered-navigation

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

如何正确发送PATCH请求

我需要调用这个REST端点

PATCH https://graph.windows.net/contoso.onmicrosoft.com/users/username@contoso.onmicrosoft.com?api-version=1.5 HTTP/1.1

{
    "<extensionPropertyName>": <value>
}
Run Code Online (Sandbox Code Playgroud)

请参阅此处的文档:https://msdn.microsoft.com/en-us/library/azure/dn720459.aspx

我有以下代码为用户设置一个属性的值:

public async Task<ActionResult> AddExtensionPropertyValueToUser()
        {
            Uri serviceRoot = new Uri(azureAdGraphApiEndPoint);
            var token = await GetAppTokenAsync();
            string requestUrl = "https://graph.windows.net/mysaasapp.onmicrosoft.com/users/usuario1@mysaasapp.onmicrosoft.com?api-version=1.5";

            HttpClient hc = new HttpClient();
                hc.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

            var method = new HttpMethod("PATCH");

            var request = new HttpRequestMessage(method, requestUrl)
            {
                Content =  new StringContent("{ \"extension_33e037a7b1aa42ab96936c22d01ca338_Compania\": \"Empresa1\" }", Encoding.UTF8, "application/json")
            };

            HttpResponseMessage hrm = await hc.GetAsync(new Uri(requestUrl));
            if (hrm.IsSuccessStatusCode)
            {
                string jsonresult = await hrm.Content.ReadAsStringAsync();
                return View("TestRestCall", …
Run Code Online (Sandbox Code Playgroud)

c# rest azure adal

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

如何使用VSTS REST API排队新版本

我有以下脚本

Param(
   [string]$vstsAccount = "abc,
   [string]$projectName = "abc",
   [string]$user = "",
   [string]$token = "xyz"
)

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$verb = "POST"


$body = @"
{

    "definition": {
         "id": 20
    }
}
"@


$uri = "https://$($vstsAccount).visualstudio.com/DefaultCollection/$($projectName)/_apis/build/builds?api-version=4.1"
$result = Invoke-RestMethod -Uri $uri -Method $verb -ContentType "application/json" -Body (ConvertTo-Json $body)  -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
Run Code Online (Sandbox Code Playgroud)

但是我得到这个错误

Invoke-RestMethod : {"$id":"1","innerException":null,"message":"This request expects an object in the request body, but the supplied data could not …
Run Code Online (Sandbox Code Playgroud)

rest powershell azure-devops

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

Azure DEVOPS 中的 GIT 错误 - SSL 证书问题:证书链中的自签名证书推送

向 Azure Devops 推送提交时,我收到此错误。

推送到远程存储库时遇到错误:Git 因致命错误而失败。无法访问“ https://xx@dev.azure.com/xx/Lulo/_git/LuloBackend/ ”:SSL 证书问题:证书链中的自签名证书推送到 https://xx@dev.azure.com/ x/Lulo/_git/LuloBackend

一开始以为是我公司的网络或者防火墙,于是切换到移动数据,但是报错还是一样。

第二件事是我最近更改了 Azure AD 帐户的密码,是否必须在 Visual Studio 中的 GIT 设置中更改某些内容?

谢谢

git visual-studio azure-devops

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

为什么一个联盟比一个组更快

好吧,也许我太老了,我想了解以下内容.

查询1.

select count(*), gender from customer
group by gender
Run Code Online (Sandbox Code Playgroud)

查询2.

select count(*), 'M' from customer
where gender ='M'
union
select count(*), 'F' from customer
where gender ='F'
Run Code Online (Sandbox Code Playgroud)

第一个查询更简单,但由于某些原因在分析器中,当我同时执行两个查询时,它表示查询2使用39%的时间,查询1,61%.

我想了解原因,也许我必须重写我的所有疑问.

sql

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

没有可用于此操作的连接:使用Azure Redis缓存时

我有以下代码用于从缓存中获取信息.我不知道我的应用程序是否打开了太多连接,或者只是这个错误是由于天蓝色redis缓存的瞬态故障造成的.

这是堆栈跟踪

[RedisConnectionException:没有可用于此操作的连接:GET UserProfileInformation|globaladmin@xx.onmicrosoft.com] 1 processor, ServerEndPoint server) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:1922 StackExchange.Redis.RedisBase.ExecuteSync(Message message, ResultProcessorc:\ TeamCity\buildAgent\work中的StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl(消息消息,ResultProcessor 1处理器,ServerEndPoint服务器)\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisBase.cs:80 StackExchange.Redis.RedisDatabase.StringGet(RedisKey key,CommandFlags标志)位于c:\ TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\RedisDatabase.cs:1431 xx.Utils.SampleStackExchangeRedisExtensions.Get(IDatabase cache,String key)位于C:\ Proyectos\xx\xx\Utils\SampleStackExchangeRedisExtensions.cs:20
xx.Cache.UserProfile.GetUserProfile(String identityname)in C:\Proyectos\xx\xx\Cache\UserProfile.cs:22
x.Controllers.UserProfileController.GetPropertiesForUser()在C:\ Proyectos\xx\xx\Controllers\UserProfileController.cs:16
lambda_method(Closure,ControllerBase,Object []) +61
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,Object []参数)+14

这是代码

   public static Models.UserProfile GetUserProfile(string identityname)
        {
            /// It needs to be cached for every user because every user can have different modules enabled.

            var cachekeyname = "UserProfileInformation|" + identityname;
            IDatabase cache = CacheConnectionHelper.Connection.GetDatabase();
            Models.UserProfile userProfile = new Models.UserProfile();
            object obj = cache.Get(cachekeyname);
            string userProfileString;
            if (obj …
Run Code Online (Sandbox Code Playgroud)

c# azure stackexchange.redis azure-redis-cache

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

如何使IObjectContextAdapter从EF 6适应EF Core

我正在尝试将此类移植到EF核心:

https://github.com/mehdime/DbContextScope/blob/master/Mehdime.Entity/Implementations/DbContextScope.cs

但是我有这个问题:

错误CS0246:找不到类型或命名空间名称'IObjectContextAdapter'(您是否缺少using指令或程序集引用?)(CS0246)(Mehdime.Entity)

还有这个:

错误CS0246:找不到类型或命名空间名称'ObjectStateEntry'(您是否缺少using指令或程序集引用?)(CS0246)(Mehdime.Entity)

所有nuget包已经在.

/* 
 * Copyright (C) 2014 Mehdi El Gueddari
 * http://mehdi.me
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */
using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;

namespace Mehdime.Entity
{
    public class DbContextScope : IDbContextScope
    {
        private bool _disposed;
        private bool _readOnly;
        private bool _completed;
        private bool _nested;
        private DbContextScope …
Run Code Online (Sandbox Code Playgroud)

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

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

用实体框架执行自定义sql?

我需要执行一个自定义查询,它将保存在数据库的某个地方,我需要它返回数据表或数据集并将其绑定到gridview,它将自动生成列为true.

我的所有数据访问层都与实体框架完美配合,但对于某些特定场景,我需要这样做,我想知道是否应该将ado.net与实体框架结合起来,或者如果EF能以某种方式实现它

c# ado.net entity-framework entity-framework-4

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