How can I get an ASP.NET MVC site running on Mono? - asp.net-mvc

I've found plenty of questions / blog posts about this, but I have not seen a repeatable recipe for getting an MVC site running on Mono. Nor have I been able to, after many hours of attempts, been able to get an MVC site to run on Mono.
I can spin up whatever version of whatever distribution is required, and can use either MVC3 or MVC4. I would prefer to use nginx, but can use mod_mono as well. I can build from source or use packages.
Can anyone give a step-by-step on getting MVC to run on Mono?
Example Error
This is what I get when I try to run a barebones app on fastcgi or xsp:
Missing method .ctor in assembly
/tmp/root-temp-aspnet-0/eaee30a1/assembly/shadow/bef1c25f
/a2978c47_1c664e18_00000001/System.Web.Providers.dll,
type System.Data.Objects.DataClasses.EdmRelationshipAttribute
Can't find custom attr constructor image:
/tmp/root-temp-aspnet-0/eaee30a1/assembly/shadow/bef1c25f
/a2978c47_1c664e18_00000001/System.Web.Providers.dll mtoken: 0x0a000012

It's very easy. Use MonoDevelop IDE http://monodevelop.com/.
Check this page http://www.integratedwebsystems.com/2011/06/get-mvc3-razor-running-on-mono/

Related

How can I access an ASP.NET MVC application through IIS Express while using OpenCover?

I am using OpenCover to cover a very simple ASP.NET MVC application. It's basically just a shell application: a handful of controller methods and not much else.
I am attempting to user OpenCover to launch an instance of IIS 8.0 Express, through which I will run the MVC application. However, when I try to browse to the site, I get an "Access is denied" 401.2 error. I have tried numerous things to solve this, mostly revolving around different ways to enable Windows Authentication. Most of my attempts have been based on advice from questions like this. Despite my efforts, I'm still getting this 401.2 error. Also, I should point out that when running this application through VS2013, I can access the site just fine.
One final detail is that in order to use OpenCover, I cannot use the full version of IIS because OpenCover and IIS don't work well together, so IIS Express is a must. If there is any sort of configuration details I can provide you with in order for you to better help me, please let me know. Thank you!

Building a First Run Installer in ASP.NET MVC

I'd like to build a web installer into my ASP.NET MVC application. It would be a first run installer that would allow the user to create a user account, set database connection strings, and configure some first run settings. I was looking at SPA's like HotTowel and OAK. Any advice on a good direction to go would be appreciated!
I've not done this myself but I know Orchard CMS http://www.orchardproject.net/ has similar to what you require. Reviewing their code might be a good place to start.

Elmah.MVC vs. Elmah.contrib.Mvc

I'm new to ASP.NET MVC and I'm looking for the least painful way to get global error handling, logging, and reporting (via email) set up. FYI, my ASP.NET MVC app is being hosted as a web role in Azure, but I'm trying to avoid using any Azure-specific hooks.
It looks like getting ELMAH installed and configured is a good first step.
When I look in NuGet, I see:
ELMAH ("ELMAH with initial configuration for getting started quickly...")
Elmah.Contrib.Mvc ("...designed to add ease-of-use inside MVC projects...")
Elmah.MVC ("...painless integration into MVC...")
Which of these packages do I want to install?
EDIT: After some experimentation, I'm more confused. I compared the project files after installing each of the three options on top of a default MVC 4 app. It appears that neither Elmah.Contrib.Mvc nor Elmah.MVC add the elmah.1.2.2 package (which I get when I install basic ELMAH). Also, neither package adds the <elmah> section to Web.config.
So... do I need to install ELMAH first, and then install one of the "...MVC" packages to get whatever nifty improvements they presumably get me?
ELMAH - This is the default ELMAH package with no mvc specific code in it, if you dont do what is described here I don't believe ELMAH will log any errors that occur in you're controllers, and you may not be able to access the ELMAH log page
Elmah.Contrib.Mvc - This is an enhancement on ELMAH specifically for MVC based upon one of the creators of ELMAHS answer to a stack overflow question.
Elmah.MVC - This is simliar to the above package however I believe it provides much better support for mvc features like routes etc, It is also quite easy to install and configure, it removes a lot of the messing around you would have to do with ELMAH to take out various parts that arent required when running in a mvc project
You can read the authors posts to get a better idea of how it works:
Integrating ELMAH to ASP.NET MVC in right way
ELMAH MVC controller released on NuGet
ELMAH.MVC v.2.0.0 - Release Candidate
Personally I believe the last package would be the best one ot use, it seems to be the more up to date and maintained of the two mvc ones.
You might consider using Elfar instead of Elmah. Elfar is "inspired" by Elmah but is designed to be MVC specific and is very simple to configure.
Just open NuGet, and search for Elfar. You will find a number of different packages, but in general you want the one that conforms to the technology you are intested in using. I'm not familiar with Azure web roles, but if you have access to a standard Sql Server then you can simply use Elfar.SqlClient.
More info here:
https://github.com/stevenbey/elfar/wiki

ASP.NET MVC 4 on Aruba

i tried to look around but i did't find a solution.
I have a web space on aruba and i want to publish the default mvc 4 internet website (you know...home, about, contacts).
I tried to publish but it dont't work.
I read about putting .aspx (useless cause no aspx pages here) or .chstml (i tried) on the route config, but nothing happend. Always HTTP Error 403.14
Does anyone tried to publish an mcv 4 website on aruba? What changes do i have to do?
I'm using Windows 2008 Hosting with, with ASP.NET 4 and Classic Pipeline
If you referring to Aruba.it hosting solutions, they doesn't support mvc projects..
Look at there Windows hosting solution
It support asp.net not asp.net mvc...
If they were support it they would have wrote it
If ASP.NET works for you, you can bundle the MVC dll's with your project (so that theres a System.web.mvc.dll in your project's bin folder.
And it should just work.
Aruba supports Mvc4. You just have to remember to publish all the dll as told by Mvison (so mvc dll, sql ce dll, and so on) and also give the write permission to that folder, otherwise they won't allow them to run (think it's a safety policy)

Deploying EF 4.1 code-first ASP.NET MVC3 to medium trust shared hosting

I think, this is quite common situation nowadays, so its surprising, that I have troubles finding nice and clean solution for it (even here at SO).
I have my ASP.NET MVC3 web application using Entity Framework 4.1 with code-first approach (using DatabaseInitializer to seed default data). I also tried two database options: SQL Express 2008 R2 and SQL Compact 4. Everything is working fine on local.
Now I want to host my app so I found hosting (middle one called 'optimal') and finally (after some issues) got into state, where I am getting medium-trust error (I believe).
The application attempted to perform
an operation not allowed by the
security policy. To grant this
application the required permission
please contact your system
administrator or change the
application's trust level in the
configuration file.
Let's take as fact that I can't configure that hosting any way and I do not think, that they are going to switch me to full-trust.
What do I have to do, to make my application work on medium-trust hosting?
Edit: I have found some answers that are usually propagating setting medium trust at local dev and just do it like that, so my question could now be something like:
What are "top 5 reasons" why your ASP.NET MVC3 EF 4.1 app won't work at medium-trust?
Edit: I have added bounty to this becuase I would like to see some discussion.. or at least more oppinions/experiences, containing more than just "set medium trust at local dev". Maybe there is nothing to discuss here, but I am just curious because I already spent more time on this than I would like.
I've seen other people complain of the same error when the server did not have .NET 3.5 Service Pack 1 and were able to work around it by putting the DLLs in their bin folder.
There's also a little more info here about a few things to check:
log4net throwing Security Exception in ASP.Net MVC web application
Do you have the latest EF Code First library? Everything before the RC was not medium trust compatible.
If you are going to use SQL CE 4, it is medium trust compatible but did you deploy the SQL CE database engine files?
Are you sure your problem is EF Code First? AKA - Have you tried just deploying a simple MVC site first and getting it running? Here's an article on setting up MVC in medium trust and another on bin deploying MVC3 for hosts who aren't running/supporting MVC3 yet.

Resources