小编Mal*_*iri的帖子

类型'Observable <Response>'上不存在属性'map'

我试图从Angular调用API但是我收到此错误:

Property 'map' does not exist on type 'Observable<Response>'

这个类似问题的答案并没有解决我的问题:Angular 2 beta.17:'Observable <Response>'类型中不存在属性'map'.

我正在使用Angular 2.0.0-beta.17.

asp.net-core-mvc visual-studio-2015 typescript1.8 angular

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

错误:未捕获(在承诺中):错误:无法匹配任何路径Angular 2

错误

我在我的应用程序中实现了嵌套路由.当应用程序在登录后加载其显示登录屏幕时,其重定向到管理页面,其中存在更多子路由,如user,product,api等.现在,当我导航到admin时,byddefault加载用户屏幕但进一步<routeLinks>无法工作,它显示此错误. Error: Uncaught (in promise): Error: Cannot match any routes: 'product'

在此输入图像描述

点击产品后,它显示了这一点 在此输入图像描述

代码main.ts

import { bootstrap }    from '@angular/platform-browser-dynamic';
import { APP_ROUTER_PROVIDERS } from '../app/app.routes';
import { AppComponent } from '../app/app.component';

bootstrap(AppComponent, [APP_ROUTER_PROVIDERS]);
Run Code Online (Sandbox Code Playgroud)

app.component

import { Component } from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';

@Component({
  selector: 'demo-app',
  template: `

    <div class="outer-outlet">
      <router-outlet></router-outlet>
    </div>
  `,
  directives: [ROUTER_DIRECTIVES]
})
export class AppComponent { }
Run Code Online (Sandbox Code Playgroud)

app.routes

import { provideRouter, RouterConfig } from '@angular/router';

import { AboutComponent, AboutHomeComponent, AboutItemComponent …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-routing

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

ASP.Net MVC中的Cookie 5

我正在开发一个应用程序,其中用户通过外部身份提供商(如AAD,Google,WS-Federated Authentication等)进行SignUp或SignIn.现在我想在用户计算机上创建cookie以登录用户SignOut.给我一些思考并指导我如何克服它.提前致谢.

c# asp.net-core-mvc

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

Angular 2 Error提供的参数与调用目标的任何签名都不匹配

我试图在按钮点击时调用post api,但是我显示了这个错误:

提供的参数与呼叫目标的任何签名都不匹配

码:

changeStatus(id) {
    this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id)
        .subscribe(
            data => this._data = data.json(),
            err => this.logError(err)
        );
}
Run Code Online (Sandbox Code Playgroud)

typescript angular

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

415不支持的媒体类型asp.net核心

详情

我试图将文件从Postman发布到我创建的端点.但它给了我这个错误.我没有在邮递员中传递标题Content-Type

415不支持的媒体类型

API

 [Consumes("multipart/form-data")]
    [HttpPost]
    public async Task<IActionResult> SendEmail([FromBody]Entity entity)
    {
        try
        {

            return OK();
        }
        catch (Exception e)
        {
            throw e;
        }
    }
Run Code Online (Sandbox Code Playgroud)

public class Entity 
{
    public List<IFormFile> Files { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-webapi asp.net-core-2.0

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

错误System.BadImageFormatException服务结构

问题

我正在构建服务结构应用程序.当我创建一个项目并运行它工作正常.但是当我在Api控制器中注入一个服务时,它给了我这个错误,我试图解决它,但还没有成功.

错误

System.BadImageFormatException无法加载文件或程序集"dotnet-aspnet-codegenerator-design"或其依赖项之一.尝试加载格式不正确的程序.

图片

在此输入图像描述

我添加了这项服务

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
        {
            return new ServiceInstanceListener[]
            {
                new ServiceInstanceListener(serviceContext =>
                    new KestrelCommunicationListener(serviceContext, "ServiceEndpoint", (url, listener) =>
                    {
                        ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting Kestrel on {url}");

                        return new WebHostBuilder()
                                    .UseKestrel()
                                    .ConfigureServices(
                                        services => services
                                            .AddSingleton<StatelessServiceContext>(serviceContext)
                                            .AddScoped(typeof(ISendMessage), typeof(SendMessage))
                                            )
                                    .UseContentRoot(Directory.GetCurrentDirectory())
                                    .UseStartup<Startup>()
                                    .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
                                    .UseUrls(url)
                                    .Build();
                    }))
            };
        }
Run Code Online (Sandbox Code Playgroud)

azure azure-service-fabric asp.net-core service-fabric-stateless

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

在c#HttpClient 4.5中发布multipart/form-data

问题

我正在尝试发布API以将数据发送到API,该API调用我的内部API服务以将该数据发送到其他API i服务.实体包含带文件的属性.这只将文件发送到另一个派生,但NameSender属性不随文件一起发送.

实体

public class Email
{

    public string NameSender{ get; set; }

    public List<IFormFile> Files { get; set; }


}
Run Code Online (Sandbox Code Playgroud)

API

[Consumes("multipart/form-data")]
[HttpPost]
public IActionResult SendEmail([FromForm]Entity entity)
{
    try
    {
        string Servicesfuri = this.serviceContext.CodePackageActivationContext.ApplicationName + "/" + this.configSettings.SendNotificationServiceName;

        string proxyUrl = $"http://localhost:{this.configSettings.ReverseProxyPort}/{Servicesfuri.Replace("fabric:/", "")}/api/values/Send";

        //attachments
        var requestContent = new MultipartFormDataContent();


        foreach (var item in entity.Files)
        {
            StreamContent streamContent = new StreamContent(item.OpenReadStream());
            var fileContent = new ByteArrayContent(streamContent.ReadAsByteArrayAsync().Result);
            requestContent.Add(fileContent, item.Name, item.FileName);

        }

        HttpResponseMessage response = this.httpClient.PostAsync(proxyUrl, requestContent).Result;


        if (response.StatusCode …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-webapi asp.net-core-2.0

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

如何使用 firebase auth 对 azure 函数进行身份验证

在解释我的问题之前,我想分享一些关于我正在尝试做的事情的见解。我正在 Azure 中开发无服务器应用程序。我的azure应用程序服务计划包含多个azure功能应用程序,每个功能应用程序都包含多个azure功能(HTTP触发器/API)。现在我想验证所有无服务器 API。我正在使用 firebase 来验证我的用户。我如何以最小且可重用的方式实现它。

我已经在 asp.net core 中使用 firebase 以整体方式进行身份验证,但对于这样的情况,我不知道该怎么做。

以整体方式。在我们的ConfigureServices方法中,我们需要注册处理身份验证所需的服务并指定Firebase项目的参数。

services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
    options.Authority = "https://securetoken.google.com/my-firebase-project";
    options.TokenValidationParameters = new TokenValidationParameters
    {
        ValidateIssuer = true,
        ValidIssuer = "https://securetoken.google.com/my-firebase-project",
        ValidateAudience = true,
        ValidAudience = "my-firebase-project",
        ValidateLifetime = true
    };
});
Run Code Online (Sandbox Code Playgroud)

然后在我们的配置方法中,我们必须执行一个简单的调用来注册将处理身份验证的实际中间件。

app.UseAuthentication();
Run Code Online (Sandbox Code Playgroud)

c# firebase-authentication azure-functions

8
推荐指数
0
解决办法
1807
查看次数

将布尔值更改为角度2客户端中的文本

详情

我试图从api获取数据并在列表中显示包含status属性,该属性返回true或false值但我想在客户端显示Active或Block而不是this.我怎样才能在角度2中实现这一点.

在此输入图像描述

typescript angular

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

Asp.net Core 非静态字段、方法或属性 'HttpContext.Session 需要一个对象引用

问题

当我将其重定向到应用程序主页索引页面以在导航栏中显示用户名时,我在成功登录后在登录控制器中设置会话我正在获取会话对接它给了我这个错误

非静态字段、方法或属性 'HttpContext.Session 需要对象引用

index.cshtml 中的代码

@if (@HttpContext.Session.GetString("Name") != null)
{
    <a href="/Account/Sigout" class="btn btn-outline-primary d-block">@HttpContext.Session.GetString("Name")</a>                
}
Run Code Online (Sandbox Code Playgroud)

asp.net-core-2.0

7
推荐指数
0
解决办法
5163
查看次数