为什么我会收到"幻数的gzip头信息是不正确的&QUOT。使用OWIN AUTH对Azure的SQL错误 [英] Why am I getting "The magic number in GZip header is not correct." error using OWIN auth against Azure SQL

查看:733
本文介绍了为什么我会收到"幻数的gzip头信息是不正确的&QUOT。使用OWIN AUTH对Azure的SQL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有在谷歌或SO涉及这一具体问题,所以提出一个新的问题。我创建了一个全新的Asp.Net MVC的 Web应用程序的符合标准的用户安全的选项。我也创造了Azure的一个空数据库。

Nothing on Google or SO relates to this specific problem, so asking a new question. I created a brand new Asp.Net MVC Web Application with the standard user-security option. I also created an empty database in Azure.

我什么也没做,但默认的连接字符串改成这样:

I did nothing but change the default connection string to this:

  <connectionStrings>
    <add name="DefaultConnection" 
         connectionString="data source=mydatabase.database.windows.net;initial catalog=Feedback;persist security info=True;user id=LeaveFeedbackuser;password=mypassword;MultipleActiveResultSets=True;App=EntityFramework"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

和默认的连接工厂这样的:

and the default connection factory to this:

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>

在试图注册(当我希望它正常创建 AspNetUsers 和相关表)我收到以下错误:

On attempting to register (when I would expect it to normally create the AspNetUsers and related tables) I get the following error:

在gzip头的幻数不正确。请确保您
  传递一个gzip流。说明:未处理的异常
  当前Web请求的执行过程中发生。请
  检查堆栈跟踪有关该错误以及更多信息
  它起源于code。

The magic number in GZip header is not correct. Make sure you are passing in a GZip stream. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:System.IO.InvalidDataException:幻数
  在gzip头信息是不正确的。请确保您在一个gzip传递
  流。

Exception Details: System.IO.InvalidDataException: The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.

源错误:

153线:{行154:VAR用户=新
  ApplicationUser {用户名= model.Email,电子邮件= model.Email};线
  155:VAR结果=等待UserManager.CreateAsync(用户,
  model.Password); 156线:如果(result.Succeeded)线路
  157:{

Line 153: { Line 154: var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; Line 155: var result = await UserManager.CreateAsync(user, model.Password); Line 156: if (result.Succeeded) Line 157: {

发生了什么任何的这种做gzip和是什么原因造成这个错误?这阻止了我越来越OWIN我好几天了,现在Azure数据库的工作。

What has any of this to do with GZip and what is causing this error? This has stopped me getting OWIN working with my Azure database for several days now.

推荐答案

因此​​,这里是我的理论。我认为在SQL Azure的数据块没有正确设置或连接字符串是错误的。

So here's my "theory". I think the Sql Azure Db is not setup correctly or the connection string is in error.

我们知道,当AspIdentity试图打在登录数据库,发现桌子都没有设立它会尝试创建它们。

We know that when AspIdentity attempts to hit the database on Login and finds the tables are not set up it will try to create them.

我认为这是在AspIdentity code崩溃/错误,在这种情况下燕子从坏的连接字符串,因此,失败的安装程序产生的异常,并继续在它试图提供一个身份验证票据的快乐的方式客户端。

I think there is a breakdown/bug in the AspIdentity code that under this circumstance swallows the exception generated from the bad connection string and thus the failed setup and continues on it's merry way trying to provide an authentication ticket to the client.

如果我们展望code的<一个href=\"https://katanaproject.$c$cplex.com/SourceControl/latest#src/Microsoft.Owin.Security/DataHandler/Serializer/TicketSerializer.cs\"相对=nofollow> Microsoft.Owin.Security.DataHandler.Serializer.TicketSerializer ,我们发现了一些动作的GZip:

If we look into the code for Microsoft.Owin.Security.DataHandler.Serializer.TicketSerializer we find some GZip action:

 public virtual byte[] Serialize(AuthenticationTicket model)
        {
            using (var memory = new MemoryStream())
            {
                using (var compression = new GZipStream(memory, CompressionLevel.Optimal))
                {
                    using (var writer = new BinaryWriter(compression))
                    {
                        Write(writer, model);
                    }
                }
                return memory.ToArray();
            }
        }

所以基本上我觉得AspIdentity的连接失败,这个错误是吞噬时,Owin管道继续处理请求,但是当它击中 TicketSerializer 也许是一个空值或者一些其他假值传递中,Gzip已试图压缩呯!

So basically I think AspIdentity fails on the connection, this error is swallowed, the Owin pipeline continues processing the request but when it hits the TicketSerializer perhaps a null value or some other bogus value is passed in which Gzip tries to zip and Boom!

怪人YSOD输出随之而来。

Weirdo YSOD output ensues.

在gzip头的幻数不正确。请确保您
  传递一个gzip流。说明:发生未处理的异常
  当前Web请求的执行过程中。请检查
  堆栈跟踪有关该错误以及它的更多信息
  起源于code。

The magic number in GZip header is not correct. Make sure you are passing in a GZip stream. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

AspIdentity没有正确短路OWIN请求处理这个特定的事件。

AspIdentity is not properly short circuiting OWIN request processing for this particular event.

也许纯属无稽之谈,但无论如何,我会扔在那里。

Probably utter nonsense but I'll throw it out there anyway.

这篇关于为什么我会收到&QUOT;幻数的gzip头信息是不正确的&QUOT。使用OWIN AUTH对Azure的SQL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆