HttpCompileException: “External exception” when trying to access razor view in ServiceStack hosted on Apache+mod_mono

雨燕双飞 提交于 2020-01-05 09:34:39

问题


I am getting HttpCompileException when trying to access a razor view. Error log contains no information. The same deployment works on NGinx+FastCGI, but not on Apache+mod_mono.

I am not using the mod_mono AutoConfiguration because I have not (yet) found a way how to make it work.

This is my "manual" apache2.conf configuration for mono:

MonoAutoApplication disabled
AddHandler mono .aspx .ascx .asax .ashx .config .cs .asmx .axd
MonoApplications "/:/var/www/MyAppName"
<Location />
    SetHandler mono
</Location>

This is the error I am getting when trying to access a razor view:

System.Web.HttpCompileException: External exception
  at ServiceStack.Razor.Compilation.RazorPageHost.Compile () [0x00000] in <filename unknown>:0 
  at ServiceStack.Razor.Managers.RazorPageResolver.EnsureCompiled (ServiceStack.Razor.Managers.RazorPage page, IHttpResponse response) [0x00000] in <filename unknown>:0 
  at ServiceStack.Razor.Managers.RazorPageResolver.CreateRazorPageInstance (IHttpRequest httpReq, IHttpResponse httpRes, System.Object dto, ServiceStack.Razor.Managers.RazorPage razorPage) [0x00000] in <filename unknown>:0 
  at ServiceStack.Razor.Managers.RazorPageResolver.ResolveAndExecuteRazorPage (IHttpRequest httpReq, IHttpResponse httpRes, System.Object model, ServiceStack.Razor.Managers.RazorPage razorPage) [0x00000] in <filename unknown>:0 
  at ServiceStack.Razor.Managers.RazorPageResolver.ProcessRequest (IHttpRequest httpReq, IHttpResponse httpRes, System.Object dto) [0x00000] in <filename unknown>:0 
  at ServiceStack.WebHost.Endpoints.Formats.HtmlFormat+<>c__DisplayClass1.<SerializeToStream>b__0 (IViewEngine x) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable.Any[IViewEngine] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0 
  at ServiceStack.WebHost.Endpoints.Formats.HtmlFormat.SerializeToStream (IRequestContext requestContext, System.Object response, IHttpResponse httpRes) [0x00000] in <filename unknown>:0 
  at ServiceStack.WebHost.Endpoints.Extensions.HttpResponseExtensions.WriteToResponse (IHttpResponse response, System.Object result, ServiceStack.ServiceHost.ResponseSerializerDelegate defaultAction, IRequestContext serializerCtx, System.Byte[] bodyPrefix, System.Byte[] bodySuffix) [0x00000] in <filename unknown>:0 

I have looked as RazorPageHost.Compile in ServiceStack sources and I can see that HttpCompileException is thrown in case result from _codeDomProvider.CompileAssemblyFromDom contains some Errors, which makes sense.

Is there some special configuration to make CodeDomProvider work on mod_mono Apache-hosted ServiceStack applications?

EDIT: It looks like this is not specific to ServiceStack, other ASP.NET apps deployed to the same server have the same issue.

来源:https://stackoverflow.com/questions/20118595/httpcompileexception-external-exception-when-trying-to-access-razor-view-in-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!