我看过有关此问题的帖子,但没有任何问题或答案与我的问题足够接近,无法提供有效的答案。
我无法通过浏览器向 API 发送请求。
据我了解,问题在于,当您向 API 网关发送请求时;浏览器将首先发送预检选项请求。此预检请求不会添加任何自定义标头,即:x-apigw-api-idheader. 这会导致返回 403,甚至没有命中选项请求。
我的理解是客户端无法控制预检请求,它由浏览器处理。
获取请求通过邮递员工作,选项请求也是如此,但前提是我x-apigw-api-id为每个请求添加标头。
通过邮递员返回的标头并x-apigw-api-id添加到请求
{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,OPTIONS","Access-Control-Allow-Headers":"Content-Type,X-Api-Key,","Content-Type":"application/json"}
我删除标题,得到一个403 forbidden.
这个问题有解决方法吗?发送选项请求时也许不需要 x-apigw-api-id ?
我在发帖之前查过的一些问题:
我正在尝试在我的资产文件夹中创建一个HTML文件,该文件不过是一些标头标签,日期和功能列表,以用作我们网站的发行说明。我有一个角度模态组件,我想在每次调用该文件的路径时都读取该文件,而不是在组件本身中包含HTML的一种选择,这需要我们在每次更新发行说明时都重新部署。
如前所述,我最初将此作为组件HTML文件的一部分,但是每次都将其编译为javascript,并且如果不重新部署就无法更新。我尝试搜索以进行类似操作的所有操作似乎都在指示我只是这样做。
ReleaseNotes.html
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<body>
<h1>Example header one</h1>
<h3>03/01/2019</h3>
<h4>Patch 1.03 Title</h4>
<ul>
<li>Feature that was added</li>
<li>Feature that was added</li>
<li>Feature that was added</li>
</ul>
<hr>
Run Code Online (Sandbox Code Playgroud)
release-notes-modal.component.ts
export class ReleaseNotesModalComponent implements OnInit {
faTimesCircle = faTimesCircle;
contents: string;
constructor(public dialogRef: MatDialogRef<ReleaseNotesModalComponent>) {
//this.contents = System.IO.File.ReadAllText("ReleaseNotes.html");
}
ngOnInit() {
}
close() {
this.dialogRef.close();
}
}
Run Code Online (Sandbox Code Playgroud) 我已经构建了一个 asp.net MVC 应用程序,该应用程序在源项目所在的同一台计算机上的 IIS 上运行良好。但是,我必须更改源项目中的一些代码,但是当我在 Visual Studio 2013 中启动我的项目时,构建过程运行并失败。它显示以下错误。
1> 'tasklist' 不被识别为内部或外部命令,
1>可运行的程序或批处理文件。
1> C:\ Program Files(x86)\ MSBuild \ 12.0 \ bin \ Microsoft.Common.CurrentVersion.targets(1131,5):错误MSB3073:命令“tasklist / fi”imagename eq iisexpress.exe“|find”: > 空
1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1131,5): 错误 MSB3073: 如果错误级别 1 taskkill /f /im "iisexpress.exe"" 退出并显示代码255.
当我运行此命令taskkill /f /im iisexpress.exe时,出现未找到进程消息。
你知道是什么原因造成的吗?
我有一个ASP.NET Core Web应用程序.用户可以登录,它使用Identity.
我现在正在使用Xamarin构建一个Android应用程序,该应用程序将提供网站的缩小部分 - 从库存中添加/删除产品.
这是登录操作:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null)
{
ViewData["ReturnUrl"] = returnUrl;
if (ModelState.IsValid)
{
var result = await _signInManager.PasswordSignInAsync (model.Email, model.Password, model.RememberMe, lockoutOnFailure: true);
if (result.Succeeded)
{
var user = await UserManager.FindByNameAsync( model.Email );
if ( !user.IsApproved ) {
await _signInManager.SignOutAsync();
_logger.LogWarning(2, "User account not approved.");
return RedirectToAction("NotApproved");
}
AddAutoLogoutCookie();
_logger.LogInformation(1, "User logged in.");
return RedirectToLocal(returnUrl);
}
if (result.RequiresTwoFactor)
{
return RedirectToAction("VerifyCode", new { Provider = AppSettings.GoogleAuthenticatorProviderName, ReturnUrl …Run Code Online (Sandbox Code Playgroud) 我对事件的理解有问题。由于某些原因,我无法订阅我的活动。视觉工作室说
错误CS0029无法将类型'void'隐式转换为'FileSystemWatcher.FileSystemWatcher.Handler'FileSystemWatcher C:\ Users \ Diord \ source \ repos \ FileSystemWatcher \ FileSystemWatcher \ Program.cs 16活动
当我这样做
fileSystemWatcher.Changed + = ShowMessage();
class Program
{
static void Main(string[] args)
{
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher("C:\\");
//next line is highlighted
fileSystemWatcher.Changed += ShowMessage();
}
public void ShowMessage()
{
Console.WriteLine("Hello Event!");
}
}
class FileSystemWatcher
{
readonly string _path;
private string[] Files { get; set; }
public FileSystemWatcher(string path)
{
_path = path;
}
public delegate void Handler();
public event Handler Changed; …Run Code Online (Sandbox Code Playgroud)