单声道MVC查找aspx文件而不是路由

时间:2014-02-05 14:30:18

标签: c# apache deployment mono centos

我正在尝试在CentOS上托管MVC3应用程序。我已经设置了Mono和apache,它可以工作,但是当我尝试访问我的网站时,我在apache日志中遇到错误:

[Wed Feb 05 15:12:16 2014] [notice] Apache/2.2.15 (Unix) DAV/2 mod_mono/2.10 configured -- resuming normal operations
mod-mono-server4
Listening on: /tmp/mod_mono_server_global
Root directory: /
[Wed Feb 05 15:12:21 2014] [error] [client 127.0.0.1] (13)Permission denied: access to /Default.aspx denied
[Wed Feb 05 15:12:21 2014] [error] [client 127.0.0.1] (13)Permission denied: access to /index.aspx denied
[Wed Feb 05 15:12:21 2014] [error] [client 127.0.0.1] (13)Permission denied: access to /Default.aspx denied
[Wed Feb 05 15:12:21 2014] [error] [client 127.0.0.1] (13)Permission denied: access to /default.aspx denied
[Wed Feb 05 15:12:21 2014] [error] [client 127.0.0.1] (13)Permission denied: access to /index.html denied
[Wed Feb 05 15:12:21 2014] [error] [client 127.0.0.1] (13)Permission denied: access to /index.html.var denied

这告诉我apache正在寻找经典的aspx页面而不是路由。如何设置以便搜索路线?

编辑:mod_mono.conf:

<IfModule !mod_mono.c>
    LoadModule mono_module /usr/lib64/httpd/modules/mod_mono.so
</IfModule>

<IfModule mod_headers.c>
    Header set X-Powered-By "Mono"
</IfModule>

<IfModule mono_module>
    #AddType application/x-asp-net .config .cs .csproj .dll .resources .resx .sln .vb .vbproj
    #AddType application/x-asp-net .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo

    MonoAutoApplication enabled
    MonoDebug true
    MonoServerPath "/opt/mono/bin/mod-mono-server4"
    MonoUnixSocket "/tmp/.mod_mono"

    <IfModule dir_module>
        DirectoryIndex Default.aspx
    </IfModule>

    <DirectoryMatch "/(bin|App_Code|App_Data|App_GlobalResources|App_LocalResources)/">
        Order deny,allow
        Deny from all
    </DirectoryMatch>

    <Location "/Mono">
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1 ::1
        SetHandler mono-ctrl
    </Location>
</IfModule>

AddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .vb
AddType application/x-asp-net .master
AddType application/x-asp-net .sitemap
AddType application/x-asp-net .resources
AddType application/x-asp-net .skin
AddType application/x-asp-net .browser
AddType application/x-asp-net .webinfo
AddType application/x-asp-net .resx
AddType application/x-asp-net .licx
AddType application/x-asp-net .csproj
AddType application/x-asp-net .vbproj
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex Default.aspx
DirectoryIndex default.aspx

在httpd.conf中,我的vhost只有ServerName nad DocumentRoot。

编辑#2 按照此处的建议http://wordpressapi.com/solved-issue-directory-index-forbidden-by-options-directive/错误消失,现在当我访问我的网站时,我会看到要浏览的文件。

现在显示日志:

[Wed Feb 05 17:02:54 2014] [notice] Apache/2.2.15 (Unix) DAV/2 mod_mono/2.10 configured -- resuming normal operations
mod-mono-server4
Listening on: /tmp/mod_mono_server_global
Root directory: /
[Wed Feb 05 17:03:06 2014] [error] [client 127.0.0.1] client denied by server configuration: /srv/www/mvc3/bin/
System.IO.FileNotFoundException: Could not load file or assembly 'mod-mono-server4, Version=2.10.2.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified.
File name: 'mod-mono-server4, Version=2.10.2.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'
  at (wrapper xdomain-invoke) System.AppDomain:CreateInstanceAndUnwrap (string,string)
  at (wrapper remoting-invoke-with-check) System.AppDomain:CreateInstanceAndUnwrap (string,string)
  at System.Web.Hosting.ApplicationHost.CreateApplicationHost (System.Type hostType, System.String virtualDir, System.String physicalDir) [0x00308] in /tmp/mono-2.10.2/mcs/class/System.Web/System.Web.Hosting/ApplicationHost.cs:269 
  at Mono.WebServer.VPathToHost.CreateHost (Mono.WebServer.ApplicationServer server, Mono.WebServer.WebSource webSource) [0x00037] in /tmp/xsp-2.10.2/src/Mono.WebServer/VPathToHost.cs:150 
  at Mono.WebServer.ApplicationServer.GetApplicationForPath (System.String vhost, Int32 port, System.String path, Boolean defaultToRoot) [0x0009e] in /tmp/xsp-2.10.2/src/Mono.WebServer/ApplicationServer.cs:583 
  at (wrapper remoting-invoke-with-check) Mono.WebServer.ApplicationServer:GetApplicationForPath (string,int,string,bool)
  at Mono.WebServer.ModMonoWorker.GetOrCreateApplication (System.String vhost, Int32 port, System.String filepath, System.String virt) [0x000f9] in /tmp/xsp-2.10.2/src/Mono.WebServer.Apache/ModMonoWorker.cs:158 
  at Mono.WebServer.ModMonoWorker.InnerRun (System.Object state) [0x000c9] in /tmp/xsp-2.10.2/src/Mono.WebServer.Apache/ModMonoWorker.cs:214 
  at Mono.WebServer.ModMonoWorker.Run (System.Object state) [0x00000] in /tmp/xsp-2.10.2/src/Mono.WebServer.Apache/ModMonoWorker.cs:92 
[Wed Feb 05 17:03:18 2014] [error] (70014)End of file found: read_data failed
[Wed Feb 05 17:03:18 2014] [error] Command stream corrupted, last command was -1
[Wed Feb 05 17:03:19 2014] [notice] child pid 5068 exit signal Segmentation fault (11)

1 个答案:

答案 0 :(得分:0)

虽然我不知道centos还没有尝试过,但是在ubuntu 14.04 LTS上已经报告了它的错误

https://bugs.launchpad.net/ubuntu/+source/xsp/+bug/1293481

问题是mod-mono-server4.exe崩溃,mod-mono-server4.exe是mod_mono的后端,mod_mono将所有asp.net请求从apache委托给mod-mono-server4.exe

我也遇到了这个问题我正在使用mono 3.2.8而且我发现了一个可以帮助你的部分解决方法,如果你使用单声道版本我将它添加到你的mod_mono.conf MonoUnixSocket之后我正在使用,您也可以在其他版本上试用

MonoPath default /path/to/mono/4.5:/path/to

它应该在此更改后工作,但在每次重新启动计算机后,它会给您一些例外情况,因此您需要重新启动Apache服务器,它将重新开始工作,

< p>

另外一件事,如果上面的更改有效并且你的mod-mono-server4.exe没有崩溃,你仍然得到浏览文件而不是尝试将它添加到你的mod_mono.conf

<IFModule mono_module>
    ForceType application/x-asp-net
........