我昨天运行了Windows Update,当我尝试发布我的ASP.NET MVC 4项目的新版本时,它引入了一些问题.
应用程序在本地编译并运行正常,但是当我将版本推送到我的网络服务器上的测试站点时,它会出现错误消息:
System.Web.HttpCompileException: (0): error CS1705: Assembly 'App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Run Code Online (Sandbox Code Playgroud)
经过一些研究后,我发现这是由于从4.0.0.0更新到4.0.0.1.我从我的项目中删除了System.Web.Mvc dll并读取了具有更高版本的dll.一切都在本地工作,但不在网络上.然后我浏览了web.config并将任何提及的4.0.0.0更改为4.0.0.1.同样,这继续在内部工作但在外部失败.错误消息是:
Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack …
我刚刚在我的机器上安装了VS2015,同时尝试了一些新的模板,我意识到IIS Express无法运行.
我在VS2012中尝试了以前工作的MVC解决方案,但是现在它也没有用.在我安装VS2012之前,这肯定是在我每天使用它.
它将启动Internet Explorer/Edge/Chrome,但在标题页中它只是说'等待localhost'.我离开了这个5-10分钟,但仍然没有找到它.
在阅读了大量其他StackOverflow问题之后,我尝试了对应用程序进行各种设置更改(我记不起来了)并删除了IIS Express目录,但没有效果.
我还在VS2012中创建了一个新的空白MVC解决方案,以确保它与解决方案相关,但这也无法正常工作.
渗透测试建议我们更改 JWT 实现以使用非对称签名而不是对称签名,这种方法运行良好。
创建对称令牌的当前(完美工作)代码如下:(灵感最初来自如何加密 JWT 安全令牌?)
private string CreateToken(string Username)
{
//Set issued at date
DateTime issuedAt = DateTime.UtcNow;
//set the time when it expires
DateTime expires = DateTime.UtcNow.AddHours(1);
JwtSecurityTokenHandler tokenHandler = new JwtSecurityTokenHandler();
//create a identity and add claims to the user which we want to log in
ClaimsIdentity claimsIdentity = new ClaimsIdentity(new[]
{
new Claim(ClaimTypes.Name, Username)
});
DateTime now = DateTime.UtcNow;
SymmetricSecurityKey securityKey = new SymmetricSecurityKey(System.Text.Encoding.Default.GetBytes(SecurityConstants.ConstSecurityEncryptionKey));
SigningCredentials signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
//create the jwt
JwtSecurityToken …Run Code Online (Sandbox Code Playgroud) 我一直在研究 IEqualityComparer 和 IEquitable。
来自诸如IEqualityComparer<T> 和 IEquatable<T> 之间有什么区别?两者之间的区别现在很明显了。“IEqualityComparer 是一个对象接口,用于对 T 类型的两个对象执行比较。”
按照https://msdn.microsoft.com/en-us/library/ms132151(v=vs.110).aspx中的示例,IEqualityComparer 的目的非常明确且简单。
我按照https://dotnetcodr.com/2015/05/05/implementing-the-iequatable-of-t-interface-for-object-equality-with-c-net/上的示例来了解如何使用它,我得到以下代码:
class clsIEquitable
{
public static void mainLaunch()
{
Person personOne = new Person() { Age = 6, Name = "Eva", Id = 1 };
Person personTwo = new Person() { Age = 7, Name = "Eva", Id = 1 };
//If Person didn't inherit from IEquatable, equals would point to different points in memory.
//This means this would be false as both …Run Code Online (Sandbox Code Playgroud)