简体   繁体   中英

What causing WebMatrix.Data.dll and WebMatrix.WebData.dll to be added to my bin directory

I have an MVC ASP.Net app that I have been working on. It works fine only about half the time when I try to load a page I get diverted to a login.aspx?ReturnUrl=ENCODED_REQUESTED_PATH_HERE . This is very frustrating after some searching on the internet I found that this was caused by

WebMatrix.Data.dll
WebMatrix.WebData.dll

When I delete these the problem does go away and after commenting out these two lines in my IISExpress applicationhost.config

<!--<add name="WebMatrixSupportModule" image="%IIS_BIN%\webmatrixsup.dll" />-->
<!--<add name="WebMatrixSupportModule" lockItem="true" />-->

The files stayed away for a while but now they are back and causing the problem again.

What is putting them in there, there is no reference to them in the project.

They are added by NuGet packages that come with ASP.NET MVC 4 project templates.

You can get more information at What is the Microsoft ASP.NET Web Pages 2 Data Nuget Package for?

These assemblies provide Simple Membership Provider that is conflicting with your authentication. Are you using forms auth & have you correctly Implemented Authorize attribute? If your controllers are marked with Authorize attributes correctly then you will not have any problem. Presence of these dll is not the problem. Your controllers are not property authorized.

For anyone who suddenly started getting WebMatrix dlls (WebMatrix.Data.dll / WebMatrix.WebData.dll) in their bin: My solution to remove them was the following:

  1. Install the nuget packages:
    • Microsoft.AspNet.WebPages.Data
    • Microsoft.AspNet.WebPages.WebData
  2. Then uninstall them.

This resulted in the following [dependentAssembly] being added to the Web.config [configuration] -> [runtime] -> [assemblyBinding]

  <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>

For some reason, despite the tag "dependent assembly", it does the opposite and prevents the WebMatrix dlls from showing up.

The reason why I personally needed to get rid of the WebMatrix dlls was because, when deployed to a server, it would ask for Razor ver.2, when I had Razor ver.3 included and in active use, throwing an exception and breaking the entire website. Just, simply, deleting the WebMatrix dlls from the server's bin folder would relieve the website of this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM