小编Eri*_*rik的帖子

HttpClient PostAsync()永远不会返回响应

我的问题与这个问题非常相似.我有一个使用HttpClient PostAsync()的authenticationService类,并且当我从ASP项目运行它时从不返回结果,但是当我在Console App上实现它时,它工作得很好.

这是我的身份验证服务类.

public class AuthenticationService : BaseService
{
    public async Task<Token> Authenticate (User user, string url)
    {
        string json = JsonConvert.SerializeObject(user);
        StringContent content = new StringContent(json, Encoding.UTF8, "application/json");

        HttpResponseMessage response = await _client.PostAsync(url, content);
        string responseContent = await response.Content.ReadAsStringAsync();
        Token token = JsonConvert.DeserializeObject<Token>(responseContent);

        return token;
    }
}
Run Code Online (Sandbox Code Playgroud)

它就在这里挂起

HttpResponseMessage response = await _client.PostAsync(url, content);

这是我的控制器调用服务

 public ActionResult Signin(User user)
    {
        //no token needed to be send - we are requesting one
        Token token =  _authenticationService.Authenticate(user, ApiUrls.Signin).Result; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asynchronous httpclient

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

用作 formControl 时,Mat Autocomplete 未设置输入值

I have a custom autocomplete component that implements ControlValueAccessor. From the parent component I am trying to set the value using form.get('productName').setValue('Product 1');. This sets the value in the form but it's not reflected in the input that is associated to the autocomplete.

I have a stackblitz example that shows the input not displaying the value. As soon as I remove the attribute [matAutocomplete]="auto" from the input, the value is visible in the UI.

https://stackblitz.com/edit/angular-autocomplete-form-control?file=src%2Fapp%2Fapp.component.ts

I have tried …

typescript angular-material angular

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

单元测试“角材料”对话框-如何包含MAT_DIALOG_DATA

我正在尝试对该材质对话框进行单元测试,以测试模板是否正在渲染正确的注入对象。正确使用该组件即可正常工作

组件-对话框

export class ConfirmationDialogComponent {

  constructor(@Inject(MAT_DIALOG_DATA) private dialogModel: ConfirmationDialogModel) {}
}
Run Code Online (Sandbox Code Playgroud)

对话框模板

<h1 mat-dialog-title *ngIf="dialogModel.Title">{{dialogModel.Title}}</h1>
<div mat-dialog-content>
  {{dialogModel.SupportingText}}
</div>
<div mat-dialog-actions>
  <button mat-button color="primary" [mat-dialog-close]="false">Cancel</button>
  <button mat-raised-button color="primary"[mat-dialog-close]="true" cdkFocusInitial>{{dialogModel.ActionButton}}</button>
</div>
Run Code Online (Sandbox Code Playgroud)

模型-正在注入什么

export interface ConfirmationDialogModel {
  Title?: string;
  SupportingText: string;
  ActionButton: string;
}
Run Code Online (Sandbox Code Playgroud)

单元测试-问题出在哪里

describe('Confirmation Dialog Component', () => {

  const model: ConfirmationDialogModel = {
    ActionButton: 'Delete',
    SupportingText: 'Are you sure?',
  };

  let component: ConfirmationDialogComponent;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        ConfirmationDialogComponent
      ],
      imports: [
        MatButtonModule,
        MatDialogModule
      ],
      providers: [ …
Run Code Online (Sandbox Code Playgroud)

unit-testing karma-jasmine angular-material2 angular angular-testing

4
推荐指数
2
解决办法
4280
查看次数

发布到 Azure 程序集后 Microsoft.Owin 无法加载

我有一个非常简单的 ASP.NET 项目,当我从 Visual Studio 运行它时工作得很好,但是在我发布到 Azure Web App 后我收到了这个错误

无法加载文件或程序集“Microsoft.Owin.Security,Version=2.0.1.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)

我四处看了看,我没有使用——至少不是故意的——这个程序集,如果我在解决方案中进行搜索,它没有列在 Web.config 或 Package.config 或任何地方。

我真的不知道我在这里错过了什么。也许是 Azure 方面的配置。

这是堆栈跟踪

[FileLoadException: Could not load file or assembly 'Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] SampleWebApp.Startup.ConfigureAuth(IAppBuilder app) +0 SampleWebApp.Startup.Configuration(IAppBuilder app) +5

[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object …

asp.net azure .net-assembly

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