Could not load file or assembly 'System.Web.He

2020-01-29 06:47发布

I have a MVC4 web application that works fine on Visual Studio 2012, using the local IIS Express Server. When I publish the application to an IIS 8 web server running on Windows 2012, the initial login page displays correctly. However, using remote debugging, I see that when I check the credentials using the following line:

if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))

I get the error shown in the figure below: System.Web.Helpers error
(source: usf.edu)

11条回答
混吃等死
2楼-- · 2020-01-29 06:55

maybe something wrong with your Web.config file. Open the file and find the <runtime></runtime> tag. modify the version of MVC. For example, MVC 3

<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>
查看更多
太酷不给撩
3楼-- · 2020-01-29 06:56

Make sure it's looking for the correct version of the file. Mine were incorrect, the web.config file was pointing to later versions than what I had in the project.

In the properties I noted the version was 2.0.0.0 so I made it this version in the web.config file

enter image description here

查看更多
乱世女痞
4楼-- · 2020-01-29 07:04

The System.Web.Helpers.dll is included in the official Nuget package Microsoft.AspNet.WebPages.

Install that and the references should be corrected, and the file should be copied to your bin folder.

查看更多
走好不送
5楼-- · 2020-01-29 07:06

I was able to resolve this by downloading the Microsoft Web Platform Installer, searching for MVC and installing the "ASP.NET MVC3 (Visual Studio 2010 ) Released 4/11/2011" package. Close any Visual Studio instance prior to installing.

查看更多
何必那么认真
6楼-- · 2020-01-29 07:06

I had the same problem working with WCF service in IIS 8. Take a look at this solution Deploying ASP.NET, it worked for me.

查看更多
冷血范
7楼-- · 2020-01-29 07:07

After adding the correct version of MVC, the reference to Microsoft Web Helper is added but not of System.Web.Helper. Add this manually to your references.

查看更多
登录 后发表回答