溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

ASP.Net MVC3安全升級(jí)導(dǎo)致程序集從3.0.0.0變?yōu)?.0.0.1

發(fā)布時(shí)間:2020-07-13 01:36:25 來(lái)源:網(wǎng)絡(luò) 閱讀:4449 作者:BoyTNT 欄目:編程語(yǔ)言

一直以來(lái),開(kāi)發(fā)MVC3應(yīng)用,在部署的時(shí)候?yàn)榱朔奖悖⒉辉谟脩舡h(huán)境安裝MVC3,只是把用到的幾個(gè)assembly直接部署到bin里,包括:

  • Microsoft.Web.Infrastructure.dll

  • System.Web.Helpers.dll

  • System.Web.MVC.dll

  • System.Web.WebPages.Deployment.dll

  • System.Web.WebPages.dll

  • System.Web.WebPages.Razor.dll


最近系統(tǒng)升級(jí),再這么部署網(wǎng)站時(shí),發(fā)現(xiàn)不好用了,報(bào)錯(cuò):

Compiler Error Message: CS1705: Assembly 'TestUnsafe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'


發(fā)現(xiàn)沒(méi)?System.Web.MVC的版本要求是3.0.0.1,而bin里放的仍然是3.0.0.0,肯定跑不起來(lái)。OK,換個(gè)新的程序集上去,把System.Web.MVC.dll 3.0.0.1版放上去,仍然跑不起來(lái),報(bào)錯(cuò):

Parser Error Message: 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)


這是由于Web.config未更新導(dǎo)致的,找到下面的幾行:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


調(diào)整oldVersion和newVersion,改成:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


看到?jīng)]?把舊版本的MVC統(tǒng)一映射到3.0.0.1版去。再訪問(wèn)站點(diǎn),一切正常了。



向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI