简体   繁体   English

在IIS上部署的MVC应用程序中进行路由

[英]Routing in MVC application deployed on IIS

I have added the following code 我添加了以下代码

public class RouteController : Controller
    {
        public ContentResult GetImpression()
        {
           // Do something
        }
    }

In RouteConfig class i have added the following 在RouteConfig类中,我添加了以下内容

routes.MapRoute(
                name: "Impression",
                url: "imp",
                defaults: new { controller = "Route", action = "GetImpression", id = UrlParameter.Optional }
            );

I am expecting my http://mymachine/imp to work. 我希望我的http://mymachine/imp可以工作。 What am i doing wrong? 我究竟做错了什么? Do i have to do some settings in IIS as well? 我也必须在IIS中进行一些设置吗?

For issues with routing I have always found the following tool from Phil Hacck to be invaluable in figuring out where I screwed up with my routing rules and what is getting called. 对于路由问题,我一直发现Phil Hacck的以下工具对于弄清我在哪里弄错了路由规则以及该如何调用非常有用。 There is nothing special you need to do in IIS to get things working. 在IIS中,您无需执行任何特殊操作即可使工作正常进行。 The one thing you probably should check is to ensure if your Application Pool is using version 4.0 and not version 2.0. 您可能应该检查的一件事是确保您的应用程序池是否使用版本4.0,而不是版本2.0。 Usually when you create a site in IIS it defaults the App Pool to 2.0. 通常,当您在IIS中创建站点时,它会将应用程序池默认设置为2.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM