小编Jit*_*mar的帖子

如果部分类继承自某个类,那么具有相同名称的所有其他部分类也应该继承相同的基类?

我在我的MVC项目中有一个Model类.

public partial class Manager : Employee
{
    public string Name {get;set;}
    public int Age {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

而这个类我在同一个项目中的App_Code文件夹中.现在我想知道我的这个类是否还需要从Employee类继承或不是?

public partial class Manager 
{
    public void SaveEmployee();
}
Run Code Online (Sandbox Code Playgroud)

我必须这样做是因为我的客户要我移动App_Code文件夹中处理数据库的所有方法.

是的,这两个类共享相同的命名空间.

.net c# asp.net-mvc partial-classes

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

使用ASP.NET MVC3 Razor进行本地化

我正在尝试使用mvc3 Razor创建我的本地化网站,我不知道该怎么做.有人可以告诉我该怎么做吗?

multilingual razor asp.net-mvc-3

6
推荐指数
0
解决办法
6296
查看次数

ViewBag和ViewData也是asp.net mvc中状态管理的一部分吗?

有人可以告诉我,ViewDataViewBag是否也是asp.net mvc状态管理的一部分?谢谢

asp.net-mvc state-management asp.net-mvc-3

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

如何在PDFsharp中获取XGraphics类

我正在使用PDFsharp生成pdf,但我无法使用XGraphics类.有人可以告诉我如何使用XGraphics类或我需要在我的应用程序中添加的dll和命名空间是什么.实际上我必须在我的dll的页眉和页脚中画一条线,并在链接http://www.pdfsharp.net/wiki/Graphics-sample.ashx#Draw_simple_lines_0上有一个方法DrawLine()使用XGraphics我无法找到的课程.

pdf pdfsharp

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

使用 ffmpeg/ffprobe 获取视频长度不起作用

我正在努力使用 FFMPEG 获取视频的长度/持续时间。下面是我从谷歌获得的代码,但是当我运行该方法时它返回空字符串。做了我能做的一切调整,但没有成功。有人可以指导我这里出了什么问题吗?

 private static void GetVideoDuration()
    {
        string basePath = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
        string filePath = basePath + @"1.mp4";            
        string cmd = string.Format("-v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1  {0}", filePath);
        Process proc = new Process();
        proc.StartInfo.FileName = Path.Combine(basePath, @"ffprobe.exe");
        proc.StartInfo.Arguments = cmd;
        proc.StartInfo.RedirectStandardError = true;
        proc.StartInfo.UseShellExecute = false;            

        if (!proc.Start())
        {
            Console.WriteLine("Error starting");
            return;
        }
        StreamReader reader = proc.StandardError;
        string line;
        while ((line = reader.ReadToEnd()) != null)
        {
            Console.WriteLine(line);
        }
        proc.Close();
    }
Run Code Online (Sandbox Code Playgroud)

c# ffmpeg ffprobe

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

使用mvc3中的DataAnnotations验证文本框以仅接受有效的日期时间值

我想使用MVC3中的DataAnnotations验证文本框以接受日期时间值.但我不知道该怎么做.鉴于以下是我正在努力完成我的要求而且它无法正常工作.

    [DataType(DataType.DateTime, ErrorMessage = "Invalid Datetime")]
    [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy HH:mm}")]
    [Display(Name = "Start Datetime")]
    public DateTime? StartDateTime { get; set; }
Run Code Online (Sandbox Code Playgroud)

当我在填写损坏的数据后点击提交按钮时,第一个问题是该表单获取帖子,之后它显示"无效日期"的消息,如果我输入的日期没有时间仍然形式获得发布,但这次它没有显示消息也是错误的.

所以我只想知道如何使用MVC DataAnnotations验证我的文本框以"dd/MM/yyyy HH:mm"格式接受日期时间.

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

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

使用"frombody"属性,Web Api方法的参数在使用Postman测试时接收空值

下面给出的是我的WebApi方法,我想用Postman测试它,但每当我提交请求时,myKey总是包含空值.

[Route("Complete")]
[HttpPost]
[Authorize]
public async Task<IHttpActionResult> Complete([FromBody]string myKey)
{
    // My logic
}
Run Code Online (Sandbox Code Playgroud)

这就是我如何通过Postman提交请求. 在此输入图像描述

我发现很多帖子建议我们如何从Web提交数据,但不是一个使用Postman显示相同的数据.

你能指导我通过Postman工具获得myKey的价值吗?

api asp.net-web-api postman

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

无法将自定义标头从WebAPI公开给客户端

我编写了一个程序来下载web api返回的pdf,word或txt文件,它运行正常.在服务器端,我使用了WebApi和客户端AngularJs.现在的问题是,我也需要来自api的文件名,为此我需要读取api返回的头文件.但reponse.headers不包含所有标题信息.以下是我的代码:

 [HttpGet]
 [Authorize]
    public HttpResponseMessage GetTranscript(string key, int format)
    {
        var badRequest = Request.CreateResponse(HttpStatusCode.OK, "Not a valid input."); //ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, "Not a valid input."));
        if (string.IsNullOrWhiteSpace(jiraTaskKey))
        {
            return badRequest;
        }

        string transcript = _mediaCaptionService.GetTranscript(UserId, key);

        string fileName = "transcript";
        var response = new HttpResponseMessage(HttpStatusCode.OK);

        if (format == (int)TranscriptFormat.PDF)
        {
            byte[] byteInfo = GeneratePDFTranscript(transcript);
            response.Content = new ByteArrayContent(byteInfo);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            fileName = fileName + ".pdf";
        }
        else if (format == (int)TranscriptFormat.TXT)
        {
            response.Content = new StringContent(transcript, System.Text.Encoding.UTF8, …
Run Code Online (Sandbox Code Playgroud)

asp.net-web-api angularjs

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

错误 TS2739:“AbstractControl”类型缺少“FormControl”类型中的以下属性:registerOnChange、registerOnDisabledChange

我是 Angular 的新手,正在学习使用Angular 10的在线课程,但有一次卡住了。我正在尝试实现Reactive 表单。为此,我添加了一个新组件text-input。的代码text-input.component.ts如下:

import { Component, Input, Self } from '@angular/core';
import { ControlValueAccessor, NgControl } from '@angular/forms';

@Component({
  selector: 'app-text-input',
  templateUrl: './text-input.component.html',
  styleUrls: ['./text-input.component.css']
})
// We need to implement a control value accessor
export class TextInputComponent implements ControlValueAccessor {
  @Input() label: string;
  @Input() type = 'text';

  constructor(@Self() public ngControl: NgControl) {
    this.ngControl.valueAccessor = this;
  }
  writeValue(obj: any): void {
  }

  registerOnChange(fn: any): void {
  }

  registerOnTouched(fn: any): void …
Run Code Online (Sandbox Code Playgroud)

angular angular-reactive-forms

2
推荐指数
3
解决办法
2894
查看次数

为什么"new Random().Next()"不返回像"random.Next()"这样的随机数?

我尝试了两种不同的方法来获得一系列随机数:

// (a) works
Random random = new Random();
return Enumerable.Range(0, 20).OrderBy(n => random.Next());

// (b) does not work
return Enumerable.Range(0, 20).OrderBy(n => new Random().Next());
Run Code Online (Sandbox Code Playgroud)

我正在使用的第一个变体random.Next()工作正常.

但是我调用的变体new Random().Next()并不返回随机数; 相反,它返回一个从0到20的数字序列.

现在我的问题是:

  • 什么术语表示new Random().Next()C#中对象的第二种初始化?
  • 它与第一个有什么不同,以至于我没有获得欲望输出?

c# random

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