I have a small web application. Which was working fine until I added two genericHandler in my application.
I have made the following changes for the http handler
<system.web> <authentication mode="Forms" > <forms protection="All" timeout="720" defaultUrl="Default.aspx" loginUrl="Login.aspx" > </forms> </authentication> <authorization> <deny users="?"/> </authorization> <compilation debug="true" targetFramework="4.0" /> <httpHandlers> <!--Code Log Handler--> <add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory" /> <add verb="*" type="InfoDomeNewUI.Handler.SendOWA" path="SendOWA.ashx" /> <add verb="*" type="InfoDomeNewUI.Handler.SendSOS" path="SendSOS.ashx" /> </httpHandlers> <customErrors mode="Off"> <error statusCode="404" redirect="Templates/PageNotFound.html" /> </customErrors> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <handlers> <!--Code Log Handler--> <add name="LogHandler1" path="SendOWA.ashx" verb="*" type="InfoDomeNewUI.Handler.SendOWA"/> <!-- SMS SENDER--> <add name="SendSOS" path="SendSOS.ashx" verb="*" type="InfoDomeNewUI.Handler.SendSOS"/> </handlers> </system.webServer> Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I am using asp.net4.0 and C#. I am not using MVC
On local host it is working fine.
But when I am hosting the published code it is giving me the above error.
Stack Trace:-
[FileNotFoundException: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.] System.Web.Http.WebHost.SuppressFormsAuthRedirectModule.Register() +0
[InvalidOperationException: The pre-application start initialization method Start on type System.Web.Http.WebHost.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..] System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +11708830 System.Web.Compilation.BuildManager.CallPreStartInitMethods() +465 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLeve
[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.Http.WebHost.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11697760 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4866485
It appears that Microsoft.Web.Infrastructure.dll is not being installed in the GAC, even if .net (4.0 or 4.5 or other) are installed successfully on Windows Server. On localhost (typically Windows client), it seems like it is being in the GAC when the tools/platform (Visual Studio etc.) are installed.
As one possible fix, please try the following:
Run the following command in the Package Manager Console. (If you are using Visual Studio, this can be reached via menu options "Tools --> Library Package Manager --> Package Manager Console:)
PM> Install-Package Microsoft.Web.Infrastructure
You will see the following messages if it is successfully installed.
Successfully installed 'Microsoft.Web.Infrastructure 1.0.0.0'. Successfully added 'Microsoft.Web.Infrastructure 1.0.0.0' to Web.
You will notice that Microsoft.Web.Infrastructure.dll has now been added as a Reference (can be seen in the references folder of your project in in Solution Explorer)
If you look at the properties of this reference you will notice that "Copy Local" has been set to "True" by default.
Now when you "Publish " your project, Microsoft.Web.Infrastructure.dll will be deployed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With