问题
I have ASP.NET with MVC and Razor markup website and I want to run it on my Linux VPS.
I have mono 3.2.8 and xsp4 3.0.0.0 version, both from Ubuntu repository (installed using apt-get install mono-complete mono-xsp4
)
When I upload my website to server and run xsp4 in the website's folder, it start and prints out that it's listening on port 8080. However when I use my web browser to navigate to my website, it displays runtime error and xsp4 outputs this to console
Missing method System.Web.HttpApplication::RegisterModule(Type) in assembly
/usr/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll, referenced
in assembly /tmp/root-temp-aspnet-0/55726984/
assembly/shadow/df4b0596/52105b83_8d5b5e15_00000001/Microsoft.Owin.Host.SystemWeb.dll
Missing method RegisterAllAreas in assembly /tmp/root-temp-aspnet-
0/55726984/assembly/shadow/dc5a60b8/51013ead_8d5b5e15_00000001/<website_name>.dll, type
System.Web.Mvc.AreaRegistration
It's a fresh Ubuntu 14.04 installation. I'm developing my website on Windows, using Visual Studio 2013. Any idea how to fix these errors?
回答1:
The upstream bug report regarding this issue is located here.
A suggested workaround until the bug is fixed and the method implemented is to use Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule
instead of HttpApplication.RegisterModule
.
The issue here describes a workaround, which would be to change HttpApplication.RegisterModule
to Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule
in PreApplicationStart.cs in OWIN (the previous master already had the relevant IFDEF for NET 4.0, but it was reverted for some reason) or to include the DLL they specify or register the module manually in the web.config .
The alternative that doesn't require any code change to OWIN is to implement the missing method in Mono and fix the bug and then backport the fix to your Mono version.
回答2:
This is not really a full answer but perhaps what I did may help someone get a little further.
After filling in some unrelated voids on the dev branch of Mono (which at the time was v3.99) like AppendTrailingBackslash(), GetBufferlessInputStream() and a few other functions, I was able to get an MVC5 app to come up and function OK on Ubuntu using XSP4.
I then tried to use OWIN and the mono-built version of SignalR.
I did what Appleman1234 suggested above, implement RegisterModule() in HttpApplication.cs to do what Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule() does. This does seem to work and injects the module string into the system.web/httpModules section without error.
This combined with manually specifying the OwinHttpHandler in my system.web:
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off" />
<httpHandlers>
<add verb="*" path="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler, Microsoft.Owin.Host.SystemWeb" />
</httpHandlers>
</system.web>
and calling the default MapSignalR() in my Startup Configuration():
var appBuilder = app.MapSignalR();
and after hacking up some of the SignalR code (I was getting some ReadOnlyException on a NameValueCollection as it tried to remove the Accept-Encoding from the request headers... I figured I'd get to that later), I think I got it to initialize all the way to the point where I could at least browse to /signalr and get some meaningful errors back (missing connectionId, unknown protocol, etc). I didn't get to actually testing the SignalR functionality, but I am about to do so by using a separate client program.
I am hosting this using xsp4/mono 4.5.
However, in doing so I think I clobbered the rest of the handlers/pipeline because I cannot really browse to anything else in the website (stylesheets, scripts, etc), as I get a 404
Also note that:
(1) HttpRuntime.UsingIntegratedPipeline
returns false in the context of XSP4.
(2) I had to comment out the exception in HttpApplication.cs/AsyncInvoker::Invoke()
, which originally threw this exception:
throw new Exception("This is just a dummy");
Given this, is there simply not yet enough Async and other support in Mono to get OWIN/SignalR to work? I am thinking that since UsingIntegratedPipeline
returns false that it's a no-go for XSP4?
来源:https://stackoverflow.com/questions/27212512/missing-method-errors-when-running-asp-net-app-with-xsp-on-linux