我的解决方案中有两个MVC网站,已转换为MVC5。对于特定测试,我需要两个网站都运行,因为一个通过Web API与另一个通信。它们使用IIS Express运行。
当我在Visual Studio(2012)中启动其中一个并访问已启动的一个时,一切正常。当我尝试访问另一个时,出现以下消息:
安全透明方法"Microsoft. Web. Helpers. PreApplicationStartCode. Start()"尝试访问安全关键方法"System. Web. WebPages. Razor. WebPageRazorHost. AddGlobalImport(System. String)"失败。
正如其他答案所建议的,我更新了我所有的软件包,并从其中一个软件包中卸载了DotNetOpenAuth
软件包,但没有结果。
这是1号研究中心的package.config
:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AntiXSS" version="4.2.1" targetFramework="net45" />
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
<package id="BeginCollectionItem" version="1.2.1.0" targetFramework="net45" />
<package id="Code52.i18n.MVC4" version="0.2.8" targetFramework="net45" />
<package id="CSS-Filters-Polyfill" version="1.0.0" targetFramework="net45" />
<package id="DotNet.Highcharts" version="2.0" targetFramework="net45" />
<package id="DotNetOpenAuth.AspNet" version="4.3.4.13329" targetFramework="net45" />
<package id="DotNetOpenAuth.Core" version="4.3.4.13329" targetFramework="net45" />
<package id="DotNetOpenAuth.OAuth.Consumer" version="4.3.4.13329" targetFramework="net45" />
<package id="DotNetOpenAuth.OAuth.Core" version="4.3.4.13329" targetFramework="net45" />
<package id="DotNetOpenAuth.OpenId.Core" version="4.3.4.13329" targetFramework="net45" />
<package id="DotNetOpenAuth.OpenId.RelyingParty" version="4.3.4.13329" targetFramework="net45" />
<package id="EntityFramework" version="6.0.1" targetFramework="net45" />
<package id="Facebook" version="6.4.2" targetFramework="net45" />
<package id="Faker" version="1.2" targetFramework="net45" />
<package id="Faker.Net" version="1.0.3" targetFramework="net45" />
<package id="Galleria.js" version="1.2.9" targetFramework="net45" />
<package id="HtmlAgilityPack" version="1.4.6" targetFramework="net45" />
<package id="ImageResizer" version="3.3.3" targetFramework="net45" />
<package id="iTextSharp" version="4.1.2" targetFramework="net45" />
<package id="jQuery" version="1.10.2" targetFramework="net45" />
<package id="jQuery.Cookie" version="1.3.1" targetFramework="net45" />
<package id="jQuery.MaskedInput" version="1.3.1.1" targetFramework="net45" />
<package id="jQuery.UI.Combined" version="1.10.3" targetFramework="net45" />
<package id="jQuery.Validation" version="1.8.1" targetFramework="net45" />
<package id="jquery-globalize" version="0.1.3" targetFramework="net45" />
<package id="knockoutjs" version="2.2.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Providers" version="1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Providers.Core" version="1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebHelpers" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.Data" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.OAuth" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.WebData" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.6" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Ajax" version="2.0.30506.0" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="2.0.30506.0" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.18" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="ModelMetadataExtensionsWithBugfix" version="0.1.2" targetFramework="net45" />
<package id="Modernizr" version="2.6.2" targetFramework="net45" />
<package id="Moq" version="4.0.10827" targetFramework="net45" />
<package id="morelinq" version="1.0.16006" targetFramework="net45" />
<package id="MvcMailer" version="4.5" targetFramework="net45" />
<package id="MvcScaffolding" version="1.0.9" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
<package id="PagedList" version="1.16.0.0" targetFramework="net45" />
<package id="PagedList.Mvc" version="4.3.0.0" targetFramework="net45" />
<package id="RazorGenerator.Mvc" version="2.1.1" targetFramework="net45" />
<package id="RazorGenerator.Testing" version="2.1.1" targetFramework="net45" />
<package id="RazorPDF" version="1.0.0" targetFramework="net45" />
<package id="ReflectionMagic" version="2.0.0" targetFramework="net45" />
<package id="RestSharp" version="104.1" targetFramework="net45" />
<package id="SendGrid" version="1.1.1" targetFramework="net45" />
<package id="System.Management.Automation" version="6.1.7601.17515" targetFramework="net45" />
<package id="System.Web.Providers" version="1.2" targetFramework="net45" />
<package id="T4Scaffolding" version="1.0.8" targetFramework="net45" />
<package id="T4Scaffolding.Core" version="1.0.0" targetFramework="net45" />
<package id="WebActivator" version="1.5.3" targetFramework="net45" />
<package id="WebActivatorEx" version="2.0.4" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>
和研究中心#2的packages.config
:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
<package id="BeginCollectionItem" version="1.2.1.0" targetFramework="net45" />
<package id="CSS-Filters-Polyfill" version="1.0.0" targetFramework="net45" />
<package id="EntityFramework" version="6.0.1" targetFramework="net45" />
<package id="Facebook" version="6.1.4" targetFramework="net45" />
<package id="ImageResizer" version="3.4.2" targetFramework="net45" />
<package id="jQuery" version="1.9.1" targetFramework="net45" />
<package id="jQuery.MaskedInput" version="1.3.1.1" targetFramework="net45" />
<package id="jQuery.UI.Combined" version="1.10.3" targetFramework="net45" />
<package id="jQuery.Validation" version="1.9.0.1" targetFramework="net45" />
<package id="jQuery-Timepicker-Addon" version="1.0.0" targetFramework="net45" />
<package id="knockoutjs" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc.Facebook" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.HelpPage" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.OData" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebHelpers" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.Data" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.WebData" version="3.1.1" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.6" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.13" targetFramework="net45" />
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Ajax" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="2.0.20710.0" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.18" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Modernizr" version="2.5.3" targetFramework="net45" />
<package id="MvcFlash.Core" version="2.0.1" targetFramework="net45" />
<package id="MvcScaffolding" version="1.0.9" targetFramework="net45" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />
<package id="T4Scaffolding" version="1.0.8" targetFramework="net45" />
<package id="T4Scaffolding.Core" version="1.0.0" targetFramework="net45" />
<package id="Twitter.Bootstrap" version="3.0.0" targetFramework="net45" />
<package id="Twitter.Bootstrap.MVC" version="2.0.0" targetFramework="net45" />
<package id="WebActivatorEx" version="2.0.4" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
<package id="XmlExport" version="0.3.2" targetFramework="net45" />
<package id="XmlOutput" version="1.0.0" targetFramework="net45" />
</packages>
我还能尝试什么?
- 编辑**
Web API调用(一个站点调用另一个站点):
if (SettingsHelper.GetCurrentSettings().IntegratedToFederated)
{
// Report Federated
var pointsGranted = new APIPointsGrantedModel();
pointsGranted.CustomerId = customerPointsPerShop.Customer.ControlKey;
pointsGranted.ShopId = (Guid)customerPointsPerShop.Shop.ControlKey;
pointsGranted.Amount = customerPointsPerShop.Points;
pointsGranted.Timestamp = DateTime.Now;
HttpClient aClient = new HttpClient();
var website = context.Settings.FirstOrDefault().FederatedWebsite;
Uri theUri = new Uri(website + "/api/APIShops/PointsGranted");
HttpResponseMessage aResponse = await aClient.PostAsync(theUri, StringContentHelper.BuildStringContent(pointsGranted, pointsGranted.GetType()));
if (aResponse.IsSuccessStatusCode)
{
var responseContent = await aResponse.Content.ReadAsAsync<APIPointsGrantedModel>();
// Read the response and perform some business logic
}
else
{
String failureMsg = "HTTP Status: " + aResponse.StatusCode.ToString() + " - Reason: " + aResponse.ReasonPhrase;
this.FlashError(failureMsg);
// TODO: Register in log.
}
}
1号研究中心web.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.4.13329" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.4.13329" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.WebData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1402.2112" newVersion="4.2.1402.2112" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="itextsharp" publicKeyToken="8354ae6d2174ddca" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="4.1.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
</assemblyBinding>
...
</configuration>
2号研究中心web.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<!-- dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly -->
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.WebData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<!-- dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.OpenId" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly -->
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<!-- dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.OAuth.Consumer" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.OAuth" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.OpenId.RelyingParty" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly -->
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.OpenId" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.OpenId.RelyingParty" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.OAuth.Consumer" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.OAuth" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1402.2112" newVersion="4.2.1402.2112" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.1.0" newVersion="5.6.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
</assemblyBinding>
...
</system.net>
</configuration>
4条答案
按热度按时间1cosmwyk1#
注意:Microsoft-Web-Helpers已替换为Microsoft. AspNet. WebHelpers。应先删除旧的程序包,然后再安装新的程序包。
我打开NuGet包管理器并安装了Microsoft.AspNet.WebHelpers包,一切都开始工作了。注意,当您创建一个新的MVC 5应用程序并尝试合并SimpleSecurity或SimpleMembership时,您将遇到相同的问题,因为默认情况下不会安装Microsoft.AspNet.WebHelpers。必须安装它,SimpleMembership才能正确运行。
我验证了参考应用程序中的所有功能在升级后都能正常工作。甚至使用邮政生成电子邮件也能正常工作,这一点我也不确定,因为Razor也升级了。
我需要对SimpleSecurity程序集做的一个更改是删除过滤器AuthorizeAttribute和BasicAuthorizeAttribute,并将它们放在一个单独的程序集中。我这样做是因为它们依赖于MVC和Web API程序集。因此,现在有一个MVC版本和另一个MVC 5版本。
参考此链接:http://ctsoftr.com/upgrading-from-asp-net-mvc-4-to-5/
aelbi1ox2#
我收到了同样的错误消息,它与一个包有关,该包已更改,但没有在所有地方正确更新(不知道为什么,不知道如何,您可以想象这个错误带来的喜悦)...我扔掉了我的packages文件夹,并重新构建了项目,瞧...仅仅几个小时后,我又回到了编码中
k7fdbhmy3#
首先,如果可能的话,我建议使用Visual Studio 2013 for MVC 5。
看起来你已经尝试了很多事情,但我重申一些事情(因为它可以帮助其他人有同样的问题),必须检查&可能是问题的原因:
1.更新所有的nuget软件包。(通过packages.config看起来你已经完成了)
1.在
global.asax
中,更改:WebApiConfig.Register(GlobalConfiguration.Configuration);
至
GlobalConfiguration.Configure(WebApiConfig.Register);
1.删除使用包管理器中的以下命令安装的以下任何ASP.NET NuGet包:
(好像你也这么做了)。
1.在web.config中,确保存在以下更改:
在
<runtime>/<assemblyBinding>
部分中,确保newVersion
正确:5
。在web.config中找到<appSettings>
部分,并将网页:版本从2.0.0.0.0更新为3.0.0.0,如下所示:6
。删除除“完全”以外的任何信任级别,例如:7.更新“视图”文件夹下的web.config文件
System.Web.Mvc
的所有元素从版本“4.0.0.0”更新为版本”5.0.0.0"。'
System.Web.WebPages.Razor
的所有元素从版本“2.0.0.0”更新为版本”3.0.0.0"。如果此节包含System.Web.WebPages
,请将这些元素从版本“2.0.0.0”更新为版本”3.0.0.0”Microsoft.AspNet.WebHelpers
:User.IsInRole()
方法,请将以下内容添加到Web.config
文件。*从项目文件中删除MVC 4项目类型GUID。
ProjectName.csproj
”。ProjectTypeGuids
元素,然后删除MVC 4项目GUID{E3E379DF-F4C6-4180-9B81-6769533ABE47}
。希望能有所帮助。
来源:www.asp.net/mvc/tutorials
k97glaaz4#
以下是完整的官方迁移指南:
How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2
主要变化包括: