日期:2014-05-17  浏览次数:20500 次

凌晨了还在加班!使用MVC2.0实现了伪静态发现本地可以,服务器上不可以了!
windws server 2003 r2 standard x64 edition service pack 2 系统  
IIS环境 6.0.

项目版本 .NET 4.0 mvc版本 2.0

伪静态的本地都可以的。发到服务器上,发现只要访问 .html 的页面都不能访问的。
另附上代码:
C# code

 public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("SiteIndex", "", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
            //装修公司首页)
            routes.MapRoute("ID", "{id}", new { controller = "Shop", action = "index", id = UrlParameter.Optional }, new { id = @"^[0-9]*$" });
            
            //分站列表页
            routes.MapRoute("Action", "{controller}", new { controller = "Home", action = "index", id = UrlParameter.Optional });
            //装修公司列表页
            routes.MapRoute("Shop3", "{id}/{action}-o{id3}-{id2}.html", new { controller = "Shop", action = "index", id = UrlParameter.Optional, id3 = UrlParameter.Optional }, new { id3 = @"^[0-9]*$", id2 = @"^[0-9]*$" });
            //装修公司列表页
            routes.MapRoute("Shop2", "{id}/{action}-o{id3}.html", new { controller = "Shop", action = "index", id = UrlParameter.Optional, id3 = UrlParameter.Optional }, new { id3 = @"^[0-9]*$", id2 = @"^[0-9]*$" });
            //装修公司列表页
            routes.MapRoute("Shop1", "{id}/{action}-{id2}.html", new { controller = "Shop", action = "index", id = UrlParameter.Optional, id2 = UrlParameter.Optional }, new { id = @"^[0-9]*$", id2 = @"^[0-9]*$" });
            //装修公司列表页
            routes.MapRoute("Shop", "{id}/{action}.html", new { controller = "Shop", action = "index", id = UrlParameter.Optional, id2 = UrlParameter.Optional }, new { id = @"^[0-9]*$" });

            //分站详细页
            routes.MapRoute("ContrHtml", "{controller}/{id}.html", new { controller = "Home", action = "detail", id = UrlParameter.Optional }, new { id = @"^[0-9]*$" });
            routes.MapRoute("Control", "{controller}/{id}", new { controller = "Home", action = "detail", id = UrlParameter.Optional }, new { id = @"^[0-9]*$" });
            
            //分站列表页
            routes.MapRoute("NoAction", "{controller}/{id}", new { controller = "Home", action = "index", id = UrlParameter.Optional });
            routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "index", id = UrlParameter.Optional });
     
     
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }




------解决方案--------------------
服务器要安装mvc2.0
iis中
“通配符应用程序映射”中插入一个映射,可执行文件交给.NET的“aspnet_isapi.dll”,默认地址一般在“C:\WINDOWS\Microsoft.NET\Framework\v版本\aspnet_isapi.dll”


http://fqctyj.blog.163.com/blog/static/70843455201022285445252/

------解决方案--------------------
领导要求那没办法,大小写肯定不区分。加通配符映射后,把上面的.html映射给删除试试,你的route有点多,最好精简下,调试下URL,看看你的URL有没有被你想要的规则匹配了,我记得有个什么工具可以看。