开发者

How to make routing in ASP.NET MVC3 Compatible in both IIS 6 and 7?

开发者 https://www.devze.com 2023-02-21 17:11 出处:网络
I have this code in Global.asax.cs: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(\"{resource}.axd/{*pathInfo}\");

I have this code in Global.asax.cs:

 public static void RegisterRoutes(RouteCollection routes)
        {

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Applications", // Route name 
                "Applications.aspx/Find/{appNum}", // URL with parameters 
                new
                {
                    controller = "Applications",
                    action = "Find"
                }, // Parameter defaults 
                new
                {
                    appNum = @"\d+"
                }  // Constraints
            );

            routes.MapRoute(
                "Default", // Route name
                "{controller}.aspx/{action}", // URL with parameters
                new
                {
                    controller = "Applications",
                    action = "Index"
                } // Parameter defaults
            );
        }

This is tuned to work for IIS 6: notice .aspx after {controller}

How can i make the same code work on both IIS 6 and IIS 7 without changing any on the IIS sid开发者_开发问答e?


you have other options.

please see the following blog post which is only written for this issue.

Running ASP.NET MVC Under IIS 6.0 and IIS 7.0 Classic Mode : Solution to Routing Problem : http://www.tugberkugurlu.com/archive/running-asp-net-mvc-under-iis-6-0-and-iis-7-0-classic-mode---solution-to-routing-problem

0

精彩评论

暂无评论...
验证码 换一张
取 消