Mono - ASP.NET Application in domain Subfolder - asp.net

I have an Apache server with mod_mono hooked up to a legacy ASP.NET application. I can't seem to get this application to work if I move it from a top level folder.
For example, the following mono .webapp successfully works at http://localhost/Service.asmx (as my web app is in folder2):
<apps>
<web-application>
<name>Test</name>
<vpath>/</vpath>
<path>/srv/aspnettest/folder1/folder2</path>
<vhost>localhost</vhost>
</web-application>
</apps>
However, due to a legacy URL, I need my web application to exist two subfolders deeper like so:
<apps>
<web-application>
<name>Test</name>
<vpath>/</vpath>
<path>/srv/aspnettest/</path>
<vhost>localhost</vhost>
</web-application>
</apps>
If I try to go to http://localhost/folder1/folder2/Service.asmx it fails with
HTTP 500. Error processing request.
Stack Trace:
System.Web.HttpException: Type MyType.Service not found.
at System.Web.UI.SimpleWebHandlerParser.GetTypeFromBin (System.String tname) [0x00000] in <filename unknown>:0
at System.Web.Compilation.SimpleBuildProvider.LoadTypeFromBin (System.Web.Compilation.BaseCompiler compiler, System.Web.UI.SimpleWebHandlerParser parser) [0x00000] in <filename unknown>:0
at System.Web.Compilation.GenericBuildProvider`1[TParser].GetGeneratedType (System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManagerCacheItem..ctor (System.Reflection.Assembly assembly, System.Web.Compilation.BuildProvider bp, System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.StoreInCache (System.Web.Compilation.BuildProvider bp, System.Reflection.Assembly compiledAssembly, System.CodeDom.Compiler.CompilerResults results) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler (System.Web.HttpContext context, System.String verb, System.String url, System.String filePath) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator2.MoveNext () [0x00000] in <filename unknown>:0
How can I successfully get a web app in subfolders? Thanks.

Turns out this was an Apache configuration issue that was unrelated but caused this as a side effect. I had my VirtualHost setup incorrectly.

Related

Error with running ASP Web application in Mac

I have created Web application in Mac OS and able to build it.
On dnx web i get the following error:
System.DllNotFoundException: libc.dylib
at (wrapper managed-to-native) System.IO.KeventWatcher:kqueue ()
at System.IO.KeventWatcher.GetInstance (IFileWatcher& watcher) <0x105a29310 + 0x000f3> in <filename unknown>:0
at System.IO.FileSystemWatcher.InitWatcher () <0x105a28fa0 + 0x0012c> in <filename unknown>:0
at System.IO.FileSystemWatcher..ctor (System.String path, System.String filter) <0x105a28d00 + 0x00114> in <filename unknown>:0
at System.IO.FileSystemWatcher..ctor (System.String path) <0x105a28cc0 + 0x00023> in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.FileSystemWatcher:.ctor (string)
at Microsoft.AspNet.FileProviders.PhysicalFilesWatcher..ctor (System.String root) <0x105a285b0 + 0x00154> in <filename unknown>:0
at Microsoft.AspNet.FileProviders.PhysicalFileProvider..ctor (System.String root) <0x105a282d0 + 0x000e4> in <filename unknown>:0
at Microsoft.AspNet.Hosting.HostingEnvironmentExtensions.Initialize (IHostingEnvironment hostingEnvironment, System.String applicationBasePath, IConfiguration config) <0x105a27f20 + 0x001ea> in <filename unknown>:0
at Microsoft.AspNet.Hosting.WebHostBuilder.Build () <0x105a1a860 + 0x000b8> in <filename unknown>:0
at Microsoft.AspNet.Hosting.WebApplication.Run (System.Type startupType, System.String[] args) <0x105560990 + 0x00216> in <filename unknown>:0
at Microsoft.AspNet.Hosting.WebApplication.Run (System.String[] args) <0x10555fef0 + 0x0001a> in <filename unknown>:0
at Microsoft.AspNet.Hosting.Program.Main (System.String[] args) <0x10555fec0 + 0x00014> in <filename unknown>:0
at Microsoft.AspNet.Server.Kestrel.Program.Main (System.String[] args) <0x10555fc90 + 0x000b5> in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1050027a0 + 0x000b7> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () in <filename unknown>:line 0
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) in <filename unknown>:line 0
at Microsoft.Dnx.ApplicationHost.Program+<>c__DisplayClass3_0.<ExecuteMain>b__0 () in <filename unknown>:line 0
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () in <filename unknown>:line 0
at System.Threading.Tasks.Task.Execute () in <filename unknown>:line 0
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at System.IO.FileSystemWatcher.Stop () in <filename unknown>:line 0
at System.IO.FileSystemWatcher.Finalize () in <filename unknown>:line 0
I have tried the suggestion in the below question
dnx kestrel "System.EntryPointNotFoundException: uv_loop_size"
and set DYLD_FALLBACK_LIBRARY_PATH.
Yet unable to resolve the issue. Any ideas to resolve it.

System.Web.HttpException with "Type Service not found." in Mono ASP.NET Web Service

I am using mono v4.2.1 and apache2 in ubuntu 14.04
I managed to install my ASP.NET web service in the url: http://myurl/WebService/Service.asmx
But when I open it, I receive this error:
System.Web.HttpException
Type Service not found.
Description: HTTP 500.Error processing request.
Details: Error processing request.
Exception stack trace:
at System.Web.UI.SimpleWebHandlerParser.GetTypeFromBin (System.String tname) <0x40f053e0 + 0x00894> in <filename unknown>:0
at System.Web.Compilation.SimpleBuildProvider.LoadTypeFromBin (System.Web.Compilation.BaseCompiler compiler, System.Web.UI.SimpleWebHandlerParser parser) <0x40f053a0 + 0x00026> in <filename unknown>:0
at System.Web.Compilation.GenericBuildProvider`1[TParser].GetGeneratedType (System.CodeDom.Compiler.CompilerResults results) <0x40f05150 + 0x00085> in <filename unknown>:0
at System.Web.Compilation.BuildManagerCacheItem..ctor (System.Reflection.Assembly assembly, System.Web.Compilation.BuildProvider bp, System.CodeDom.Compiler.CompilerResults results) <0x40f04fc0 + 0x00101> in <filename unknown>:0
at System.Web.Compilation.BuildManager.StoreInCache (System.Web.Compilation.BuildProvider bp, System.Reflection.Assembly compiledAssembly, System.CodeDom.Compiler.CompilerResults results) <0x40f04a60 + 0x0009f> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) <0x40f00ff0 + 0x00b94> in <filename unknown>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) <0x40ee7490 + 0x00579> in <filename unknown>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) <0x40ee6df0 + 0x00149> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) <0x40ee6a30 + 0x000b7> in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) <0x40ee65c0 + 0x00024> in <filename unknown>:0
at System.Web.UI.WebServiceParser.GetCompiledType (System.String inputFile, System.Web.HttpContext context) <0x40ee65a0 + 0x00014> in <filename unknown>:0
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetCompiledType (System.String url, System.Web.HttpContext context) <0x40ee6570 + 0x00022> in <filename unknown>:0
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler (System.Web.HttpContext context, System.String verb, System.String url, System.String filePath) <0x40edf510 + 0x0014a> in <filename unknown>:0
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String pathTranslated) <0x40edf050 + 0x00241> in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) <0x40ed71f0 + 0x002f3> in <filename unknown>:0
at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) <0x40ed71b0 + 0x00020> in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () <0x40ebcf60 + 0x02b62> in <filename unknown>:0
This is my Service.asmx:
<%# WebService Language="C#" Class="Service" %>
And the Service class is in a library which is added by reference:
using System.Web.Services;
[WebService(Namespace = "http://myurl/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : WebService
{
public Service()
{
}
}
The point is it works completely OK in Microsoft Visual Studio but mono has a problem and I don't know where to look or what to do.
I figured out that it was because the root directory was not correctly set.
I used xsp4 instead of apache2 and it fixed.

Issue after updating to mono 4.0.1 on Ubuntu

I just upgraded to the just released Mono version 4.0.1 on my ubuntu machines. The previous installed version of mono was 3.2.7 (if I remember correctly).
Now the issue:
My first issue is regarding SignalR and self-hosting. I have a .NET 4.5.1 console application in which I self host NancyFx, Web Api and SignalR using OWIN. When running on mono 3.2.7 there was no issues to my knowledge but when I try to start the application on mono 4.0.1 I get the following stack trace:
Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidProgramException: Invalid IL code in (wrapper delegate-invoke) <Module>:invoke_callvirt_CancellationTokenRegistration_CancellationToken&_Action`1<object>_object (System.Threading.CancellationToken&,System.Action`1<object>,object): IL_0057: castclass 0x00000007
at Microsoft.AspNet.SignalR.Infrastructure.CancellationTokenExtensions.SafeRegister (CancellationToken cancellationToken, System.Action`1 callback, System.Object state) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeResolverDispose (IDependencyResolver resolver, CancellationToken hostShutdownToken) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeHost (IDependencyResolver resolver, System.String instanceName, CancellationToken hostShutdownToken) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.UseSignalRMiddleware[HubDispatcherMiddleware] (IAppBuilder builder, System.Object[] args) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.RunSignalR (IAppBuilder builder, Microsoft.AspNet.SignalR.HubConfiguration configuration) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions+<>c__DisplayClass1.<MapSignalR>b__0 (IAppBuilder subApp) [0x00000] in <filename unknown>:0
at Owin.MapExtensions.Map (IAppBuilder app, PathString pathMatch, System.Action`1 configuration) [0x00000] in <filename unknown>:0
at Owin.MapExtensions.Map (IAppBuilder app, System.String pathMatch, System.Action`1 configuration) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.MapSignalR (IAppBuilder builder, System.String path, Microsoft.AspNet.SignalR.HubConfiguration configuration) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.MapSignalR (IAppBuilder builder, Microsoft.AspNet.SignalR.HubConfiguration configuration) [0x00000] in <filename unknown>:0
at Owin.OwinExtensions.MapSignalR (IAppBuilder builder) [0x00000] in <filename unknown>:0
I have no clue to what this error could mean and I'm greatful for all assistance. I'm using Microsoft ASP.NET SignalR Self Host package version 2.2.0.
And as a side note, I've compiled all my assemblies on the new mono version.
Kind regards,
Simon
This turned out to be a Mono issue which was recently fixed: https://bugzilla.xamarin.com/show_bug.cgi?id=29665

How to serve favicon.ico and robots.txt files from ASP.NET MVC3 application

ASP.NET MVC3 application is hosted in Apache in Mono as virtual host with address http://www.mysite.com
Requests for files robots.txt , favicon.ico and apple-touch-icon.png cause 404 error below since
there are no MVC3 controllers for those names.
How to server those files ? It it possible to force Apache to serve them as regular files or can we force MVC3 application to return those files ?
Which is proper way to implement this ?
System.Web.HttpException: The controller for path '/robots.txt' was not found or does not implement IController.
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance (System.Web.Routing.RequestContext requestContext, System.Type controllerType) [0x00000] in <filename unknown>:0
at System.Web.Mvc.DefaultControllerFactory.CreateController (System.Web.Routing.RequestContext requestContext, System.String controllerName) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.ProcessRequestInit (System.Web.HttpContextBase httpContext, IController& controller, IControllerFactory& factory) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler+<>c__DisplayClass6.<BeginProcessRequest>b__2 () [0x00000] in <filename unknown>:0
at System.Web.Mvc.SecurityUtil+<>c__DisplayClassb`1[System.IAsyncResult].<ProcessInApplicationTrust>b__a () [0x00000] in <filename unknown>:0
at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0 (System.Action f) [0x00000] in <filename unknown>:0
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust (System.Action action) [0x00000] in <filename unknown>:0
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust[IAsyncResult] (System.Func`1 func) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContextBase httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContext httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback cb, System.Object extraData) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator3.MoveNext () [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0
Fixing robots.txt:
Right click the project name and select "Add->New Item"
Choose "Text File" and call it "robots.txt"
You can leave this file blank
Fixing favicon.ico:
Go to the RegisterRoutes method of the Global.asax.cs file and add this near the top: You can look at this page for more info: Favicon Icon-MVC3 ASP.NET
routes.IgnoreRoute("{*favicon}", new { favicon = #"(.*/)?favicon.ico(/.*)?" });
Fixing apple-touch-icon.png:
Look at these websites
Why am I getting error for apple-touch-icon-precomposed.png
http://mathiasbynens.be/notes/touch-icons

asp.net on mono Failed to map path '/'

I installed mono from source on a Centos 6.4 to test a msc asp web site.
It seems to work fine all but
some pages return this error
System.InvalidOperationException
Failed to map path '/'
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object):
System.Web.
at System.Web.HttpRequest.MapPath (System.String virtualPath, System.String baseVirtualDir, Boolean allowCrossAppMapping) [0x00000] in <filename unknown>:0
at System.Web.HttpRequest.MapPath (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Hosting.HostingEnvironment.MapPath (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Hosting.DefaultVirtualPathProvider.DirectoryExists (System.String virtualDir) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.FindWebConfig (System.String path, System.Boolean& inAnotherApp) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration (System.String path, System.String site, System.String locationSubPath, System.String server, System.String userName, System.String password, Boolean fweb) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path) [0x00000] in <filename unknown>:0
at System.Web.Security.SqliteMembershipProvider.Initialize (System.String name, System.Collections.Specialized.NameValueCollection config) [0x00000] in <filename unknown>:0
at System.Web.Configuration.ProvidersHelper.InstantiateProvider (System.Configuration.ProviderSettings providerSettings, System.Type providerType) [0x00000] in <filename unknown>:0
at System.Web.Configuration.ProvidersHelper.InstantiateProviders (System.Configuration.ProviderSettingsCollection configProviders, System.Configuration.Provider.ProviderCollection providers, System.Type providerType) [0x00000] in <filename unknown>:0
at System.Web.Security.Membership..cctor () [0x00000] in <filename unknown>:0
I did the same thing on a debian and It works fine.
Do you have any suggestions?
Find all your Server.MapPaths and change from
Server.MapPaths(#"\")
to
Server.MapPaths(Path.DirectorySeparatorChar)
Have you checked the paths in your view files? Just as a reminder:
'/' like in <script src="/myScript.js"></script> maps to the DocumentRoot folder defined on your /sites-available/.conf, it may be something like /var/www
'~/' like in <script src="#Url.Content("~/scripts/script1.js")"></script> maps to the path where your mvc application is, it may be somethin like /var/www/site1
'../' would try to access one folder above the DocumentRoot folder. This may actually be forbbiden by your apache site configuration (recommended).
Also note that if your run your mvc app from monodevelop/xspServer the document root and the mvc application path are actually the same but if you install your mvc app on apache they may not be the same path.
This error occurs because there is a bug in mono System.Web
It contain this check (https://github.com/mono/mono/blob/mono-3.2.1-branch/mcs/class/System.Web/System.Web/HttpRequest.cs#L1565)
if (!isAppVirtualPath && !virtualPath.StartsWith (appVirtualPath, RuntimeHelpers.StringComparison))
throw new InvalidOperationException (String.Format ("Failed to map path '{0}'", virtualPath));
To fix this, you can comment those lines in Mono surce code and re-compile Mono.
This bug is in latest Mono also.
Links:
https://bugzilla.xamarin.com/show_bug.cgi?id=24457
I had the same error, with exactly the same stacktrace.
It only occured on the first request when apache was just started. The error did not occur after the first request.
I solved this by removing WebMatrix.WebData.dll
This will probably have some consequences when you use SimpleMembershipProvider and it might affect OpenAuth functionality on MVC4.

Resources