asp.net-mvc-2 – Mono MVC 2主路由不起作用
发布时间:2020-12-16 04:25:51 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试将ASP .NET MVC 2应用程序转换为在nginx / mono 2.8上运行.到目前为止它似乎工作得很好,除了当路径为空时默认路由不起作用.我将所有请求代理到fastcgi服务器,我得到了一个ASP .NET 404找不到的页面. 即这不起作用 http://mysite.com 但这样做 http
我正在尝试将ASP .NET MVC 2应用程序转换为在nginx / mono 2.8上运行.到目前为止它似乎工作得很好,除了当路径为空时默认路由不起作用.我将所有请求代理到fastcgi服务器,我得到了一个ASP .NET 404找不到的页面.
即这不起作用 http://mysite.com 但这样做 http://mysite.com/home 我的Global.asax.cs文件看起来像这样 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace MyProject { public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // Default route routes.MapRoute( "Default",// Route name "{controller}/{action}/{id}",// URL with parameters new { controller = "Home",action = "Index",id = UrlParameter.Optional },// Parameter defaults new string[] {"MyProject.Controllers"} ); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); } } } 编辑: 解决方法
我实际上遇到了同样的问题并且完全错误地解决了它(至少在我的情况下)…
在mono项目的网站上的nginx walkthrough中,它说要在你的nginx.conf文件中输入这些行: index index.html index.htm default.aspx Default.aspx; fastcgi_index Default.aspx; 好吧,我在两个虚拟机上以完全相同的方式(或者我认为)设置了它.问题是,一个VM有它的根URL工作而一个没有.事实证明,我忘记了VM上“索引”行上的分号,因此’fastcgi_index’行被解释为’index’行的一部分. 所以在没有工作的VM上,我删除了那个分号.你猜怎么着?有效.然后我添加了分号并完全删除了’fastcgi_index’行,它仍然有效.因此,基于这个轶事证据和一些猜测工作,我会说’fastcgi_index’行不应该包含在MVC应用程序中.好吧,至少MVC 3,我没有测试过任何其他东西. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – IIS 6.0和.Net 4的Default.aspx?
- 在asp.net-mvc网站上,处理可编辑和只读视图是否有良好的模式
- 带有声明性数据的Eval绑定ASP.NET
- asp.net – 什么是Kestrel(vs IIS/Express)
- asp.net-mvc – 删除Id MVC 5
- 剃刀 – 在身份3中创建声明身份
- .net – 尝试激活“MyDbContext”时无法解析“DatabaseConf
- asp.net-web-api – WebApi2属性路由404
- asp.net-mvc – 如何在asp.Net MVC Razor中单击Check Box的
- asp.net – JQuery Live()无效
推荐文章
站长推荐
- ASP.Net页面生命周期
- asp.net – RequiredFieldValidator必须单击两次
- asp.net-mvc – 如何在ASP.NET MVC中生成完整的t
- asp.net-mvc – ASP.NET MVC中Controller.ReadFr
- asp.net-mvc – 限制每个动作的HTTP动词
- asp.net-mvc – 检测到潜在的危险Request.Form值
- asp.net – 如何阻止.net中的libwww-perl访问?
- asp.net-core – 在Visual Studio CTP2中的ASP.V
- asp。net内置委托
- asp.net – 将SQL计数结果存储到变量VB中
热点阅读