我试图从Angular调用API但是我收到此错误:
Property 'map' does not exist on type 'Observable<Response>'
这个类似问题的答案并没有解决我的问题:Angular 2 beta.17:'Observable <Response>'类型中不存在属性'map'.
我正在使用Angular 2.0.0-beta.17.
我在我的应用程序中实现了嵌套路由.当应用程序在登录后加载其显示登录屏幕时,其重定向到管理页面,其中存在更多子路由,如user,product,api等.现在,当我导航到admin时,byddefault加载用户屏幕但进一步<routeLinks>无法工作,它显示此错误.
Error: Uncaught (in promise): Error: Cannot match any routes: 'product'
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)
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)
import { provideRouter, RouterConfig } from '@angular/router';
import { AboutComponent, AboutHomeComponent, AboutItemComponent …Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,其中用户通过外部身份提供商(如AAD,Google,WS-Federated Authentication等)进行SignUp或SignIn.现在我想在用户计算机上创建cookie以登录用户SignOut.给我一些思考并指导我如何克服它.提前致谢.
我试图在按钮点击时调用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) 我试图将文件从Postman发布到我创建的端点.但它给了我这个错误.我没有在邮递员中传递标题Content-Type
415不支持的媒体类型
[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) 我正在构建服务结构应用程序.当我创建一个项目并运行它工作正常.但是当我在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
我正在尝试发布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)
[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) 在解释我的问题之前,我想分享一些关于我正在尝试做的事情的见解。我正在 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) 当我将其重定向到应用程序主页索引页面以在导航栏中显示用户名时,我在成功登录后在登录控制器中设置会话我正在获取会话对接它给了我这个错误
非静态字段、方法或属性 'HttpContext.Session 需要对象引用
@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)