当我尝试EndRequest使用嵌套HttpModule在MVC 5.2.2和.NET 4.6.2上的事件处理程序修改标头时,我有一些奇怪的行为.如果我不在EndRequest我的顶级修改HttpModule,看起来嵌套中的事件处理程序HttpModule永远不会触发,即使我知道Init在嵌套上调用了HttpModule.
我的问题是,我的代码中发生了什么,以防止"TestNested"标题出现在响应头中,除非我包含添加了一个EndRequest什么都不做的事件处理程序的注释掉的代码?
动态注册我的顶级 HttpModule
[assembly: PreApplicationStartMethod(typeof(PreApplicationStartClass), "Start")]
namespace MyNamespace
{
public class PreApplicationStartClass
{
public static void Start()
{
DynamicModuleUtility.RegisterModule(typeof(TopHttpModule));
}
}
}
Run Code Online (Sandbox Code Playgroud)
从单个顶级模块调用Init我的所有其他HttpModules模块
namespace MyNamespace
{
public class TopHttpModule: IHttpModule
{
private readonly Lazy<IEnumerable<IHttpModule>> _modules =
new Lazy<IEnumerable<IHttpModule>>(RetrieveModules);
private static IEnumerable<IHttpModule> RetrieveModules()
{
return DependencyResolver.Current.GetServices<IHttpModule>();
}
public void Init(HttpApplication context)
{
var modules = _modules.Value;
foreach (var …Run Code Online (Sandbox Code Playgroud) 我正在使用Entity Framework Core 2.2与NetTopologySuite 1.15.1和SQL Server 2016.拥有一个类型的列IPoint非常有用,我想在它上面创建一个索引.
我有这张桌子
public class Location
{
public int Id { get; set; }
public IPoint Coordinates { get; set; }
public static void Register(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Location>(entity => entity.HasIndex(x => new {x.Coordinates}));
}
}
Run Code Online (Sandbox Code Playgroud)
EF核心在生成迁移时处理得很好,从而生成以下代码:
migrationBuilder.CreateIndex(
name: "IX_Locations_Coordinates",
schema: "data",
table: "Locations",
column: "Coordinates");
Run Code Online (Sandbox Code Playgroud)
但是,只要我尝试将迁移应用到数据库,SqlException就会抛出以下消息
SqlException:表'data.Locations'中的列'Coordinates'的类型无效,无法用作索引或统计信息中的键列.
SQL Server的确实对类型的列支持索引geography.
我相信原因可能是EF Core试图创建一个常规索引而不是空间索引.
我做错了什么还是不支持?有没有办法告诉EF Core它应该创建空间索引?
c# sql-server sqlgeography nettopologysuite entity-framework-core