小编use*_*376的帖子

类型'void'上不存在属性'subscribe'.Angular 2 asp.net核心

当我尝试使用订阅时,我收到以下错误.我在.map中遇到了同样的问题,但我通过替换以下文件解决了这个问题:https://raw.githubusercontent.com/Microsoft/TypeScript/Fix8518/lib/typescriptServices.js

我已将Typescript更新为1.8.6并更新了visual studio 2015以更新3.

我不知道如何解决这个问题,或者如果我做错了什么,我也补充说

import 'rxjs/Rx'; 
Run Code Online (Sandbox Code Playgroud)

到bootstrap和app.component类,仍然是同样的错误.

服务代码:

import { Injectable } from 'angular2/core';
import {Http, URLSearchParams} from "angular2/http";
import 'rxjs/add/operator/map';

@Injectable()
export class MediaItemService {

constructor(public http: Http) {
    this.http = http;
}

//functions
get() {
   // return this.mediaItems;
    this.http.get("/api/MediaItem").map(response => { response.json() });
}
}
Run Code Online (Sandbox Code Playgroud)

使用服务的类:

import {Component, Inject} from 'angular2/core';
import 'rxjs/Rx'; 
import {MediaItemComponent} from './media-item.component';
import {CategoryListPipe} from './category-list.pipe';
import {MediaItemService} from './media-item.service';

@Component({
selector: 'media-item-list',
directives: [MediaItemComponent],
pipes: [CategoryListPipe],
providers: [MediaItemService],
templateUrl: 'app/media-item-list.component.html', …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular

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

单点登录与web api和asp.net mvc 5

我希望将SSO与web api 2.2一起用于多种应用,包括mobile和asp.net mvc 5.

我有通过web api创建身份验证令牌的基本想法,但我几乎没有问题:

1-将身份验证令牌与用户名一起存储在cookie中是否安全?

2-我可以将身份验证与mvc中的身份框架联系起来并且能够使用角色吗?

3-如何验证角色?我是否必须向每个标记为具有特定角色授权的控制器发送请求到api,以确保它对用户来说是正确的角色?

4-如果我从Web应用程序登录并获取身份验证令牌,然后尝试从移动设备登录,它是否会发送相同的令牌?

authentication asp.net-mvc single-sign-on asp.net-web-api owin

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

angular 2路由需要单击两次以触发ngOnInit

问题是在路由中,我必须单击两次以触发ngOnInit代码。

奇怪的是,如果我有两个路由:A和B,并且我首先单击A,它将仅触发构造函数,如果我单击B,则将在调用B的构造函数之前触发A的onInit。

使用angular 2.0.0-rc.4和路由3.0.0-beta.2

页面加载时显示的错误:

vendors.js:2291 Unhandled promise rejection Error: Cannot match any routes: ''
at Observable._subscribe (http://localhost:54037/js/app.js:19280:28)
at Observable.subscribe (http://localhost:54037/js/app.js:56291:60)
at Observable._subscribe (http://localhost:54037/js/app.js:56328:26)
at MergeMapOperator.call (http://localhost:54037/js/app.js:26178:21)
at Observable.subscribe (http://localhost:54037/js/app.js:56291:36)
at Observable._subscribe (http://localhost:54037/js/app.js:56328:26)
at MergeMapOperator.call (http://localhost:54037/js/app.js:26178:21)
at Observable.subscribe (http://localhost:54037/js/app.js:56291:36)
at Observable._subscribe (http://localhost:54037/js/app.js:56328:26)
at MapOperator.call (http://localhost:54037/js/app.js:56831:21)
Run Code Online (Sandbox Code Playgroud)

gulp文件

/// <binding Clean='default, clean, resources' />
/*
This file in the main entry point for defining Gulp tasks and using Gulp     plugins.
Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007
*/

var gulp = require('gulp');
var …
Run Code Online (Sandbox Code Playgroud)

javascript angular-ui-router ngroute angular

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

使用带有身份服务器 4 的 oidc 客户端静默登录

我正在尝试在 oidc-client 中实现静默登录以与 Angular 2 一起使用

如何使用 oidc 客户端静默检查用户是否已登录(idsvr4)并显示登录详细信息。

以下代码有效,但我需要刷新页面

idsvr 4 客户端

  // JavaScript Client
            new Client
            {
                ClientId = "js",
                ClientName = "JavaScript Client",
                AllowedGrantTypes = GrantTypes.Implicit,
                AllowAccessTokensViaBrowser = true,


                RedirectUris = { "http://localhost:5002/callback.html" },

                PostLogoutRedirectUris = { "http://localhost:5002/index.html" },
                AllowedCorsOrigins = { "http://localhost:5002" },

                AllowedScopes =
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile,
                    "api1",

                },
                    RequireConsent=false,
                AllowOfflineAccess = true
            }
Run Code Online (Sandbox Code Playgroud)

客户端代码

  // JavaScript Client
            new Client
            {
                ClientId = "js",
                ClientName = "JavaScript Client",
                AllowedGrantTypes = GrantTypes.Implicit,
                AllowAccessTokensViaBrowser = true,


                RedirectUris …
Run Code Online (Sandbox Code Playgroud)

javascript openid-connect asp.net-core identityserver4 angular

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

Asp.net 5 MVC 6,添加facebook电子邮件的权限

我想知道如何为Facebook外部登录添加更多权限,特别是电子邮件.外部登录工作正常,但我似乎无法将用于MVC 5的相同代码复制到这个中,所以这就是我现在所拥有的:

        services.Configure<FacebookAuthenticationOptions>(options =>
        {
            options.AppId = Configuration["Authentication:Facebook:AppId"];
            options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
            options.Scope.Add("email");

        });
Run Code Online (Sandbox Code Playgroud)

但它不会添加电子邮件权限.

这是我在MVC 5中使用的代码以及Facebook SDK nugget:

app.UseFacebookAuthentication(new FacebookAuthenticationOptions
        {
            AppId = "XXXXXX",
            AppSecret = "XXXXXXX",
            Scope = { "email" },
            Provider = new FacebookAuthenticationProvider
            {
                OnAuthenticated = async context =>
                {
                     context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
                }
            }
        });
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc facebook asp.net-core-mvc asp.net-core

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