1、MVC要部署在Mono上面要把MVC的EntityFrameWork框架在引用中先去除掉,Microsoft.Web.Infrastructure复制本地设置为false
2、修改配置文件Web.Config 将
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="v11.0" /> </parameters> </defaultConnectionFactory> </entityFramework>
上述关于entityFramework的代码删除
3、在linux的/etc/apache2/sites-available/创建一个站点MVCTest
<VirtualHost *:80> ServerName meidaytest.linode-test.com # ServerAlias go-mono.net ServerAdmin web-admin@meidaysolution.linode-test.com DocumentRoot /var/www/meidaytest.linode-test.com/ #DocumentRoot /var/www/meidaytest.linode-test.com/ # MonoServerPath can be changed to specify which version of ASP.NET is hosted # mod-mono-server1 = ASP.NET 1.1 / mod-mono-server2 = ASP.NET 2.0 # For SUSE Linux Enterprise Mono Extension, uncomment the line below: # MonoServerPath meidaysolution.linode-test.com "/opt/novell/mono/bin/mod-mono-server2" # For Mono on openSUSE, uncomment the line below instead: MonoServerPath meidaytest.linode-test.com "/usr/bin/mod-mono-server4" # To obtain line numbers in stack traces you need to do two things: # 1) Enable Debug code generation in your page by using the Debug="true" # page directive, or by setting <compilation debug="true" /> in the # application's Web.config # 2) Uncomment the MonoDebug true directive below to enable mod_mono debugging MonoDebug meidaytest.linode-test.com true # The MONO_IOMAP environment variable can be configured to provide platform abstraction # for file access in Linux. Valid values for MONO_IOMAP are: # case # drive # all # Uncomment the line below to alter file access behavior for the configured application MonoSetEnv meidaytest.linode-test.com MONO_IOMAP=all # # Additional environtment variables can be set for this server instance using # the MonoSetEnv directive. MonoSetEnv takes a string of 'name=value' pairs # separated by semicolons. For instance, to enable platform abstraction *and* # use Mono's old regular expression interpreter (which is slower, but has a # shorter setup time), uncomment the line below instead: # MonoSetEnv mvctest.linode-test.com MONO_IOMAP=all;MONO_OLD_RX=1 ErrorLog ${APACHE_LOG_DIR}/meidaytest.linode-test.com.error.log MonoApplications meidaytest.linode-test.com "/:/var/www/meidaytest.linode-test.com/" <Location "/"> Allow from all Order allow,d MonoSetServerAlias meidaytest.linode-test.com SetHandler mono SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary </Location> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript </IfModule> </VirtualHost> eny
执行a2ensite 再执行service apache2 restart 就可访问站点了
遇到的问题:
1、采用post上传文本时设置post的大小利用下面的maxRequestLength
<location > <system.web> <httpRuntime maxRequestLength="2097151" requestValidationMode="2.0"/> </system.web> </location>
2、上传带有链接的内容时加下面的内容再在controller层加上
<httpRuntime maxRequestLength="2097151" requestValidationMode="2.0"/> <pages validateRequest="false" controlRenderingCompatibilityVersion="4.0">
[ValidateInput(false)] [HttpPost]