ASP.NET MVC Preview 5 on Mono - asp.net-mvc

Does anyone have any information about getting the current versions of ASP.NET MVC (Preview 5) working on Mono 2.0? There was info on the old versions (Preview 2, maybe Preview 3), but I've seen no details about making Preview 5 actually work.
The Mono Project Roadmap indicates ASP.NET 3.5 for Mono 2.4 (next year). Any ideas on how to get this useful before then?
More details: The basic MVC Preview 5 template seems to work, so long as I avoid the root directory. If I request the root, I get:
Server Error in '/' Application
The virtual path '' maps to another application.
Description: HTTP 500. Error processing request.
Stack Trace:
System.Web.HttpException: The virtual path '' maps to another application.
at System.Web.HttpContext.RewritePath (System.String filePath, System.String pathInfo, System.String queryString, Boolean setClientFilePath) [0x00000]
at System.Web.HttpContext.RewritePath (System.String path, Boolean rebaseClientPath) [0x00000]
at System.Web.HttpContext.RewritePath (System.String path) [0x00000]
at MvcApplication1._Default.Page_Load (System.Object sender, System.EventArgs e) [0x00000]
at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000]
at System.Web.UI.Control.LoadRecursive () [0x00000]
at System.Web.UI.Page.ProcessLoad () [0x00000]
at System.Web.UI.Page.ProcessPostData () [0x00000]
at System.Web.UI.Page.InternalProcessRequest () [0x00000]
at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000]
Version information: Mono Version: 2.0.50727.42; ASP.NET Version: 2.0.50727.42

Well a potential is that RewritePath to / has some sort of bug, so just avoid that. Changing the RewritePath(Request.ApplicationPath) to:
HttpContext.Current.RewritePath("/Home/Index");
Seems to fix the problem, and at least the demo works so far.

Asp.Net MVC 1.0 will work with the 2.4 branch of mono but you will still need to fix the RewritePath in page load of default.aspx.cs

Are you using Mono from svn or stable?
What kind of webserver are you using?
What kind of Operating system?
Do you have rewrite rules in your web server?
I can run preview 4 in Linux with this in the page_load method in default.aspx.cs
HttpContext.Current.RewritePath(Request.ApplicationPath);
((IHttpHandler)new MvcHttpHandler()).ProcessRequest(HttpContext.Current);
I need that in windows sometimes too.
I didn't test version 5 in Linux yet, so it might not work.

Related

Visual Studio for Mac: Guid should contain 32 digits with 4 dashes (xxxx...)

I'm a noob for Visual Studio for Mac. My intention was to check out Xamarin development. My Visual Studio version is 7.3 (Build 799) Community Edition, I've installed on a MB Pro 2015 Mid model.
When I try to create a project in following way,
Multiplatform
App
Games (iOS, Mac)
SpriteKit Game (2D)
And then proceeded with the steps until pressing the create button giving project name and all it just gives me the following Alert and I cannot create the project.
Updated:
I found following Log by going to "Open Log Directory" menu item.
ERROR [2017-12-14 00:46:07Z]: The project could not be created
System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
at System.Guid+GuidResult.SetFailure (System.Guid+ParseFailureKind failure, System.String failureMessageID, System.Object failureMessageFormatArgument, System.String failureArgumentName, System.Exception innerException) [0x00034] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/guid.cs:200
at System.Guid+GuidResult.SetFailure (System.Guid+ParseFailureKind failure, System.String failureMessageID) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/guid.cs:184
at System.Guid.TryParseGuidWithNoStyle (System.String guidString, System.Guid+GuidResult& result) [0x0000e] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/guid.cs:611
at System.Guid.TryParseGuid (System.String g, System.Guid+GuidStyles flags, System.Guid+GuidResult& result) [0x000f8] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/guid.cs:451
at System.Guid..ctor (System.String g) [0x00029] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/guid.cs:244
at Xamarin.AndroidDesigner.MonoDevelop.AndroidDesignerInitializer+<>c.<SupportsObject>b__1_0 (System.String g) [0x00000] in /Users/vsts/agent/2.126.0/work/3/s/Xamarin.Designer.Android/Xamarin.AndroidDesigner.MonoDevelop/AndroidDesignerInitializer.cs:23
at System.Linq.Enumerable.Any[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x0002c] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/AnyAll.cs:38
at Xamarin.AndroidDesigner.MonoDevelop.AndroidDesignerInitializer.SupportsObject (MonoDevelop.Projects.WorkspaceObject item) [0x00014] in /Users/vsts/agent/2.126.0/work/3/s/Xamarin.Designer.Android/Xamarin.AndroidDesigner.MonoDevelop/AndroidDesignerInitializer.cs:23
at MonoDevelop.Projects.WorkspaceObject.InitializeExtensionChain () [0x00091] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceObject.cs:382
at MonoDevelop.Projects.WorkspaceObject.EnsureInitialized () [0x00021] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceObject.cs:74
at MonoDevelop.Projects.MSBuild.MSBuildProjectService.CreateProject (System.String typeGuid, MonoDevelop.Projects.ProjectCreateInformation info, System.Xml.XmlElement projectOptions, System.String[] flavorGuids) [0x00046] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildProjectService.cs:526
at MonoDevelop.Projects.ProjectService.CreateProject (System.String typeAlias, MonoDevelop.Projects.ProjectCreateInformation info, System.Xml.XmlElement projectOptions, System.String[] flavorGuids) [0x00000] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectService.cs:341
at MonoDevelop.Ide.Templates.ProjectDescriptor.CreateItem (MonoDevelop.Projects.ProjectCreateInformation projectCreateInformation, System.String defaultLanguage) [0x0012b] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectDescriptor.cs:140
at MonoDevelop.Ide.Templates.SolutionDescriptor.CreateEntry (MonoDevelop.Projects.ProjectCreateInformation projectCreateInformation, System.String defaultLanguage) [0x001e9] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SolutionDescriptor.cs:161
at MonoDevelop.Ide.Templates.ProjectTemplate.CreateWorkspaceItem (MonoDevelop.Projects.ProjectCreateInformation cInfo) [0x00000] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplate.cs:311
at MonoDevelop.Ide.Templates.ProjectTemplatingProvider.ProcessTemplate (MonoDevelop.Ide.Templates.DefaultSolutionTemplate template, MonoDevelop.Ide.Projects.NewProjectConfiguration config, MonoDevelop.Projects.SolutionFolder parentFolder) [0x0000e] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplatingProvider.cs:67
at MonoDevelop.Ide.Templates.ProjectTemplatingProvider.ProcessTemplate (MonoDevelop.Ide.Templates.SolutionTemplate template, MonoDevelop.Ide.Projects.NewProjectConfiguration config, MonoDevelop.Projects.SolutionFolder parentFolder) [0x00000] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplatingProvider.cs:58
at MonoDevelop.Ide.Templates.TemplatingService+<ProcessTemplate>d__13.MoveNext () [0x00024] in /Users/builder/data/lanes/5402/df590420/source/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/TemplatingService.cs:150
Has anybody out there encountered this kind of an issue? Any solutions or workarounds you already have worked out?
So the problem seems to be that if one of the project types used by the project template is unsupported then an unknown project type is created with an empty flavor guid. This then causes an exception in the Android designer.
In this case the Xamarin.iOS project type was considered to be unsupported since Xamarin.iOS was not installed.
This seems to be a bug in Visual Studio for Mac. Either the project template should not attempt to create a Xamarin.iOS project if it is not supported, or the unknown project should be created with no flavor guids instead of using an empty string.

Error 500 while running a Fluent NHibernate Project with Visual Studio 2015 for Mac

So, I'm trying to run an ASP.NET MVC 5 with NHibernate and FluentNHibernate targeting SQL Server 2012 with Visual Studio 2015 for Mac and XSP Webserver, and it fails with the exception below. I'm using .NET Framework 4.5 and packages are updated to the very last version.
System.ArgumentNullException
Value cannot be null.
Parameter name: type
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Core.
Exception stack trace:
at System.Dynamic.Utils.ContractUtils.RequiresNotNull (System.Object value, System.String paramName) [0x00003] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/Common/src/System/Dynamic/Utils/ContractUtils.cs:67
at System.Linq.Expressions.Expression.Convert (System.Linq.Expressions.Expression expression, System.Type type, System.Reflection.MethodInfo method) [0x0000b] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/UnaryExpression.cs:780
at System.Linq.Expressions.Expression.Convert (System.Linq.Expressions.Expression expression, System.Type type) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/UnaryExpression.cs:763
at NHibernate.Util.DelegateHelper.BuildPropertySetter[T] (System.Type type, System.String propertyName) [0x00015] in <1c5d1dfd6b734554b068885679d8b49d>:0
at NHibernate.AdoNet.SqlClientSqlCommandSet..cctor () [0x00019] in <1c5d1dfd6b734554b068885679d8b49d>:0
Maybe this is a NHibernate or FluentNHibernate bug?
I think I've found a solution. Because of a bug or something, we need to configure the database with a batch size of zero to avoid this exception:
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2012.ConnectionString(
x => x.FromConnectionStringWithKey("ConexaoBanco")).ShowSql())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<HomeController>())
.ExposeConfiguration(cfg => cfg.SetProperty("adonet.batch_size", "0"))
.BuildSessionFactory();
I should give proper credit to sta-blockhead for the solution: http://sta-blockhead.blogspot.com.br/2009/06/systemdatasqlclientsqlcommandset.html

F# ionide websharperserverclient - how to run

I have a problem with running websharperserverclient template app from ionide project generator, and cannot find any information on the web how to do it - the closest thing i got was this question - I actually tried to run it with xsp4 in the project folder (where the Web.config file is) but every time got a 404 (screenshot attached: xsp4 error). Of course before starting xsp i run the ./build.sh (or FAKE build) script and it finishes with no errors. I had no problems with websharpersuave and websharperspa project templates (the second one runs with xsp4 and works like a charm).
EDIT
The error message in text form:
System.Web.HttpException
The resource cannot be found.
Description: HTTP 404.The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Details: Requested URL: /
Exception stack trace:
at System.Web.StaticFileHandler.ProcessRequest (System.Web.HttpContext context) <0x4202aa80 + 0x00733> in <filename unknown>:0
at System.Web.DefaultHttpHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback callback, System.Object state) <0x4202a400 + 0x00153> in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () <0x42012000 + 0x04416> in <filename unknown>:0
at System.Web.HttpApplication.Tick () <0x42010800 + 0x00057> in <filename unknown>:0
Yes, there seem to be issues with running the OWIN module with xsp, which I'm investigating. In the meantime, you can switch to using WebSharper's HttpModules by doing the following:
Uncomment the nodes that are indicated as pertaining to the HttpModule in Web.config (namely, the nodes system.web/httpModules and system.webServer/modules).
Remove the NuGet dependencies on WebSharper.Owin and Microsoft.Owin.Host.SystemWeb (and make sure that the corresponding dlls are deleted from your bin folder).
Remove or comment out Startup.fs.

How to publish an ASP.NET MVC application to a free host

I'm building an ASP.NET MVC application and I'm trying to deploy it on a free host (0000free) which does support ASP.NET. I tried a couple of things, but none of them worked (i.e. I only see the directory structure when I browse to my web site):
Publishing to a local folder and then copying the published files via ftp over to my host (in the public_html directory).
Publishing via ftp to the root folder: ftp.mywebsite.com
Publishing via ftp to the public_html folder: ftp.mywebsite.com/public_html
Usually I would just drop the html files in the public_html folder, but I'm getting the feeling that the deployment process for an MVC application is slightly different. Do I have to modify the Web.config or some other filer? How does one usually deploy an MVC application (on a free host)?
Update:
I have learned that the host uses Mono and supports .NET 4.0, but I'm still not able to deploy.
I have Visual Studio 2010 and I used its Publish Feature (i.e. right click on the project name and click publish) and I tried several things:
Publish method: FTP to the root folder.
Publish method: FTP to the publich_html folder.
Publish method: File System to the root folder.
Publish method: File System to the publich_html folder.
Publish method: File System to a local directory on my computer and then FTP to root and also tried the public_html folder.
I went into the cPanel (control panel) to try and see if ASP.NET has to be added/enabled for my web site, but I didn't see anything there.
I can't browse to Index.aspx nor can I redirect to it from index.html (as suggested from other posts on the host forum), right now I have a link from index.html to Index.aspx but it's not working either (see http://www.mydevarmy.com)
I've also tried renaming Index.aspx to Default.aspx, but that doesn't work either.
The search utility of the forum of the host is somewhat weak, so I use google to search their forum: http://www.google.com/search?q=publish+asp.net+site%3A0000free.com%2Fforum%2F&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a
I've been reading Pro ASP.NET MVC Framework and they have a chapter about publishing, but it doesn't provide any specific information with respect to the location of publishing, this is all they say (and it's not very helpful in my case):
Where Should I Put My Application?
You can deploy your application to any
folder on the server. When IIS first
installs, it automatically creates a
folder for a web site called Default
Web Site at c:\Inetpub\wwwroot\, but
you shouldn’t feel any obligation to
put your application files there. It’s
very common to host applications on a
different physical drive from the
operating system (e.g., in
e:\websites\ example.com). It’s
entirely up to you, and may be
influenced by concerns such as how you
plan to back up the server.
Here is the error I get when I try to view my Index.aspx page:
Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config line 1)
Description: HTTP 500. Error processing request.
Stack Trace:
System.Configuration.ConfigurationErrorsException: Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config line 1)
at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationSection.DoDeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationSection.DeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0
at System.Configuration.Configuration.GetSection (System.String path) [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.Configuration.WebConfigurationManager.GetWebApplicationSection (System.String sectionName) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManager.get_CompilationConfig () [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.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
If your hosting provider supports ASP.NET MVC then your deployment process shouldn't be any different than the one for a normal ASP.NET application. If it doesn't you could attempt a bin-deployment. And here's another article on MSDN.
It turns out that the Mono version does not support MVC, so I had to change my host to one that supports ASP.NET MVC. I had to dish out some cash, but "good hosting" isn't free. Anyway, thanks for the help everybody!

ASP.NET mvc on mono 2.2

I am having a trouble. I am trying to run asp.net mvc 1.0 on mono 2.2.I have copied the system.web.mvc.dll to bin directory. I have done HttpContext.Current.RewritePath("/Home/Index");. Still I am having te error:
Server Error in '/' Application The incoming request does not match any route
Description: HTTP 500. Error processing request.
Stack Trace:
System.Web.HttpException: The incoming request does not match any route at System.Web.Routing.UrlRoutingHandler.ProcessRequest (System.Web.HttpContextBase httpContext) [0x00000] at System.Web.Routing.UrlRoutingHandler.ProcessRequest (System.Web.HttpContext httpContext) [0x00000] at System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] at MvcApplication4._Default.Page_Load (System.Object sender, System.EventArgs e) [0x00000] at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] at System.Web.UI.Control.LoadRecursive () [0x00000] at System.Web.UI.Page.ProcessLoad () [0x00000] at System.Web.UI.Page.ProcessPostData () [0x00000] at System.Web.UI.Page.InternalProcessRequest () [0x00000] at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000]
Version information: Mono Version: 2.0.50727.1433; ASP.NET Version: 2.0.50727.1433
I have finally managed to get it running. It seems that ASP.NET 3.5 MVC applications work just fine unmodified with the latest mono from svn(they do NOT on mono 2.2).
Detailed instructions for compiling it are here: http://www.mono-project.com/Compiling_Mono_From_SVN
Obviously, you need to copy the System.Web.Mvc.dll to the bin/ subdirectory of your application.
In case anyone needs Mono and xsp on 32bit Linux, here is my build: http://www.speedyshare.com/283727620.html
UPDATE: The 2.4 release is out, go get it!
Another UPDATE: 2.6.1 is the latest release as of 3/15/2010
As has been mentioned in another question, it will work with 2.4. I'm very much of the belief that it will not work with anything else than that, although 2.2 does have coverage of the routing in .NET 3.5 SP1...
Here is a "is it plugged in" question - did you move over your Global.asax file? The #1 cause for the error you are seeing is a missing Global.asax as that file contains all your routes.
Well, I didn't change anything in my global.asax file. Using .net it runs perfectly. This error happens in case I use mono.

Resources