小编CSh*_*ark的帖子

Azure CloudBlobContainer.CreateIfNotExists返回403禁止

我在Web API服务中间接调用CloudBlobContainer.CreateIfNotExist(请参阅下面的FindOrCreatePrivateBlobContainer方法),但它返回以下403禁止的错误消息:

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The remote server returned an error: (403) Forbidden.
</ExceptionMessage>
<ExceptionType>Microsoft.WindowsAzure.Storage.StorageException</ExceptionType>
<StackTrace>
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.Exists(Boolean primaryOnly, BlobRequestOptions requestOptions, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.CreateIfNotExists(BlobContainerPublicAccessType accessType, BlobRequestOptions requestOptions, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.CreateIfNotExists(BlobRequestOptions requestOptions, OperationContext operationContext) at [Obfuscated].DocumentManagement.BlobStorage.BlobHelper.FindOrCreatePrivateBlobContainer(String ContainerName, String AccountConnectionString) in c:\Users\[Obfuscated]\Desktop\[ProjectNameObfuscated]Online\[Obfuscated].DocumentManagement.BlobStorage\BlobHelper.cs:line 25 at [Obfuscated].DocumentManagement.BlobStorage.BlobFileItemHandler.GetStream(Int64 FileItemId) in c:\Users\[Obfuscated]\Desktop\[ProjectNameObfuscated]Online\[Obfuscated].DocumentManagement.BlobStorage\BlobFileItemHandler.cs:line 114 at [Obfuscated].DocumentManagement.Service.Controllers.FileItemController.Get(String ServiceAuthKey, Int64 FileItemId) in c:\Users\[Obfuscated]\Desktop\[ProjectNameObfuscated]Online\[Obfuscated].DocumentManagement.Service\Controllers\FileItemController.cs:line 148 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at …
Run Code Online (Sandbox Code Playgroud)

c# asp.net azure-storage

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

Asp.Net Core 2.1:设置部分视图默认位置格式

我知道在Asp.Net中可以为Global.asax中的部分视图设置默认位置格式,并且我知道在Asp.Net Core中可以为类似于以下视图的视图设置ViewLocationFormats:

        //  services is of type IServiceCollection
        services.AddMvc(options =>
        {
            options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
        })
        .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
        .AddRazorOptions(options =>
        {
            // {0} - Action Name
            // {1} - Controller Name
            // {2} - Area Name
            // Replace normal view entirely
            options.ViewLocationFormats.Clear();
            options.ViewLocationFormats.Add("/Features/{1}/{0}.cshtml"); //Features/{Controller Name}/{Action Name}.cshtml
            options.ViewLocationFormats.Add("/Features/{1}/Views/{0}.cshtml"); //Features/{Controller Name}/Views/{Action Name}.cshtml
            options.ViewLocationFormats.Add("/Features/Shared/{0}.cshtml"); //Features/Shared/{Action Name}.cshtml
            options.ViewLocationFormats.Add("/Features/Shared/Views/{0}.cshtml"); //Features/Shared/Views/{Action Name}.cshtml                
        });
Run Code Online (Sandbox Code Playgroud)

对于我的一生,我不知道如何设置局部视图的位置格式?

由于Razor引擎似乎无法找到部分视图,因此以下代码部分将无法工作:

    public async Task<PartialViewResult> EntityChangeDetailModal(EntityChangeListDto entityChangeListDto)
    {
        var output = await _auditLogAppService.GetEntityPropertyChanges(entityChangeListDto.Id);

        var viewModel = new EntityChangeDetailModalViewModel(output, entityChangeListDto);

        return PartialView("_EntityChangeDetailModal", viewModel);
    }
Run Code Online (Sandbox Code Playgroud)

我知道我可以为部分视图显式传递相对路径,但是我希望能够仅更新默认位置,以便Razor引擎可以解析这些引用,而无需我对现有代码库进行大量更改。

asp.net-mvc razor

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

提取图像文件元数据

我希望能够在不打开文件的情况下提取图像的元数据和扩展属性.换句话说,当您在Windows中右键单击文件并选择"详细信息"选项卡时,如何以编程方式访问所显示的信息?

截图

使用.Net Framework 4.5及更高版本执行此操作的正确方法是什么?我已经找到了各种方法来做到这一点,但文章都提到了.Net Framework 2,至少可以说是单调乏味且可能已经过时了.具体来说,是否有任何库使这容易做到?

编辑

我需要能够以下列格式获取图像的高度和宽度尺寸:png,jpg,jpeg,gif,bmp和pdf(可以安全地假设pdf仅包含1页).

c# windows

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

EF6嵌套事务

我有一个命令服务类,它利用工作单元模式,使用各种方法通过实体框架更新数据库(在本例中为SQL Azure).

命令服务通过对dbcontext实例的引用进行实例化,dbcontext的生命周期由我选择的DI框架管理.

某些命令服务类'方法在事务中包含对数据库的多个更新,例如:

public void UpdateStuff(someEntity)
{
    using(var tx = _db.Database.BeginTransaction())
    {
        //Some updates to db
        _db.SaveChanges();
        //Some other updates to db
        _db.SaveChanges();
        tx.Commit();
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,其中一些方法在其事务中调用命令类的其他方法,例如:

public void UpdateWithSomeCascadingStuff(someOtherEntity)
{
    using(var tx = _db.Database.BeginTransaction())
    {
        //Some updates to db
        _db.SaveChanges();

        //Some other cascading logic and updates to db
        var relatedEntityToUpdate = _query.GetSomeEntityToUpdate(someOtherEntity);
        UpdateStuff(relatedEntityToUpdate);
        _db.SaveChanges();
        tx.Commit();
    }
}
Run Code Online (Sandbox Code Playgroud)

显然,通过这样做,我正在为同一个DbContext实例嵌套EF事务.

这是否受到支持,是否会造成任何麻烦?我可以选择其他方法吗?

更新:我正在使用EF6 Code First

c# entity-framework entity-framework-6

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

EFCore.BulkExtensions 无法使用 Guid PK 进行插入

我正在使用 EFCore.BulkExtensions 将具有 GUID / UniqueIdentifier 主键的实体插入到我的数据库中,但当我调用此行时,我收到以下异常:

System.InvalidOperationException HResult=0x80131509 Message=来自数据源的 String 类型的给定值无法转换为指定目标列的 uniqueidentifier 类型。
源 = EFCore.BulkExtensions StackTrace:在 EFCore.BulkExtensions.SqlBulkOperation.Insert[T](DbContext 上下文,IList 1 entities, TableInfo tableInfo, Action1 进度)在 EFCore.BulkExtensions.DbContextBulkExtensions.BulkInsert[T](DbContext 上下文,IList 1 entities, BulkConfig bulkConfig, Action1 进度)
在 MyCompany.Abp。D:\Projects\MySystem\Modules\s\s.SearchServices.Infrastruct.UnscConsolidatedList\Infrastruct\s\MonitoringBatch\MonitoringBatchSearchJob 中的EfCore.BulkExtensions.BulkInsert[TEntity、TPrimaryKey](IRepository 2 repository, IList1 实体、BulkConfigbulkConfig、操作1 记录)。 1 progress) in D:\Projects\MySystem\Utilities\MyCompany.Abp.EfCore\BulkExtensions.BulkInsert.cs:line 21 at s.SearchServices.Infrastructure.UnscConsolidatedList.Infrastructure.s.MonitoringBatch.MonitoringBatchSearchJob.PerformScreening(Guid sourceId, IListcs:第 96 行位于 D:\Projects\MySystem\Modules\s\s.SearchServices.Infrastruct.UnscConsolidatedList\Infrastruct\s\ 中的 s.SearchServices.Infrastruct.UnscConsolidatedList.Infrastruct.s.MonitoringBatch.MonitoringBatchSearchJob.ExecuteJob(MonitoringBatchSearhJobArgs args) MonitoringBatch\MonitoringBatchSearchJob.cs:第 82 行位于 s.SearchServices.Infrastruct.UnscConsolidatedList.Core.BatchSearchJobBase`1.Execute(TBatchSearhJobArgs args),位于 D:\Projects\MySystem\Modules\s\s.SearchServices.Infrastruct.UnscConsolidatedList\Core\ BatchSearchJobBase.cs:第 28 行

内部异常 1:InvalidCastException:无法将参数值从字符串转换为 Guid。

内部异常 2:InvalidCastException:从“System.String”到“System.Guid”的转换无效。

抛出异常的代码:

        public static void BulkInsert<TEntity, …
Run Code Online (Sandbox Code Playgroud)

entity-framework sqlbulkcopy ef-code-first ef-core-2.2

5
推荐指数
0
解决办法
864
查看次数

MVC 3:使用EditorForModel隐藏ID属性

我在我的视图中有这一行:

@Html.EditorForModel()
Run Code Online (Sandbox Code Playgroud)

这是我的ViewModel:

public class CommentForm
{
    public int Id { get; set; }

    [DisplayName("Kommentar"), DataType(DataType.MultilineText)]
    public string Comment { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

问题是Id在表单中呈现为文本字段.实际上,我只想Id在表单中使用动作.是否有一个属性告诉编辑器不要呈现属性Id?

asp.net-mvc data-annotations asp.net-mvc-3

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

参考错误:未定义内部绑定

在 ASP.NET Zero 5.x 中,npm run create-bundles失败。

我正在 ASP.NET Zero 的 ASP.NET Core MVC + jQuery 基础解决方案上构建一个基于 ASP.NET Boilerplate 框架的许可项目。这不是一个新的/薄荷项目,而是一个过去已经成功构建和运行的现有项目。

我遵循了入门指南以确保我安装了以下内容:

  • nodejs (v10.15.3) + npm (v6.4.1)
  • gulp - 确保我全局安装了它(cli 版本 2.0.1 本地版本 3.9.1)
  • 纱线 (v1.13.0)
  • 捆绑器和压缩器 Visual Studio 扩展(最新)

然后yarn我按照指南跑了(两次 - 我第一次收到错误消息)。

尝试运行npm run create-bundles给我以下错误消息:

似乎没有生成我缩小的 JavaScript 文件

我该怎么做npm run create-bundles才能成功运行?

node.js npm gulp asp.net-core aspnetboilerplate

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

C#interactive在代码中跳过断点?

在对代码中的问题进行故障排除时,我经常使用CSharp interactive来对我的某些API执行查询.

但是,我注意到,当我在API代码中的某处放置断点时,从C#Interactive窗口调用contains方法时,不会触发断点.

我做错了什么,或者有没有办法让C#交互式脚本在我的API中遇到断点?

我对VS调试器的工作方式知之甚少,所以任何帮助都将不胜感激.

c# visual-studio c#-interactive

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