我需要X-Frame-Options: SAMEORIGIN从我的一些操作中删除标题,这些操作应该为iframe呈现内容.只要它被添加到默认我在禁用它的请求Startup.cs:services.AddAntiforgery(o => o.SuppressXFrameOptionsHeader = false);.然后我写了一个简单的中间件:
app.Use(async (context, next) =>
{
context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
await next();
});
Run Code Online (Sandbox Code Playgroud)
回答跨域请求所需的操作使用结果过滤器属性进行修饰:
public class SuppresXFrameOptionFilter : ResultFilterAttribute
{
public override async Task OnResultExecutionAsync(ResultExecutingContext context,
ResultExecutionDelegate next)
{
context.HttpContext.Response.Headers.Remove("X-Frame-Options");
await next();
}
}
Run Code Online (Sandbox Code Playgroud)
这就是疲惫.第一个跨域请求失败,因为尽管过滤器最终按预期工作,但X-Frame-Options: SAMEORIGIN仍然存在于响应中(我next()在中间件之后检查了它- 标题重新出现).如果我按F5,标题不再出现在响应中,一切正常.只有X-Frame-Options标题才会发生这种情况,正确删除自定义标题.什么使X-Frame-Options被删除的内容再次出现在响应中?
我IMemoryCache在我的项目中使用.我想知道如果我的应用程序在缓存中推送许多长生命对象会发生什么.它可以占用所有可用的内存吗?我可以全局定义应用程序的最大内存吗?
我需要在视图中从资源文件中获取一些字符串.在Startup.cs中:
services.AddMvc()
.AddViewLocalization(options => options.ResourcesPath = "Resources");
Run Code Online (Sandbox Code Playgroud)
和:
app.UseRequestLocalization(new RequestCulture("ru-RU"));
Run Code Online (Sandbox Code Playgroud)
视图:
@using Microsoft.AspNet.Mvc.Localization
@inject IViewLocalizer loc
Run Code Online (Sandbox Code Playgroud)
我在MSDN博客中读到以下内容:
这
IViewLocalizer是一种IHtmlLocalizer基于当前视图名称查找资源的服务.
那么我应该如何命名.resx文件以便我的本地化字符串出现在我的视图中?如果我有,Views/Manager/Index.cshtml那么Resources/Manager/Index.cshtml.ru-RU.resx是正确的吗?但资源尚未找到......
我有使用加密技术的ASP.Net Core 1.0.0应用程序.我需要使用解密密钥RSACryptoServiceProvider.Visual Studio建议将System.Security.Cryptography.Csp4.0.0版添加到我的依赖项中.我接受了,在Windows上它一切正常.但是当我在Ubuntu 16.04上部署它时,RSACryptoServiceProvider方法开始抛出PlatformNotSupportedException异常.我使用错误的装配吗?我找到https://github.com/dotnet/corefx/tree/v1.0.0/src/System.Security.Cryptography.Csp并且有1.0.0版本.这就是我需要的吗?如何将其添加到我的项目中?