URL模式路由MVC 3 [英] URL Pattern Routing MVC 3

查看:98
本文介绍了URL模式路由MVC 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何获得在url像这样在asp.net MVC

I want to know how to have something like this in the url in asp.net MVC

/Article/12.20.2013

/Article/12.20.2013

下面我想其工作罚款/条/二零一三年十二月二十日而不是/Article/12.20.2013。下面我有在Global.asax

I tried below and its working fine for /Article/12-20-2013 but not for /Article/12.20.2013. I have below in the Global.asax

routes.MapPageRoute("Blog",
    "/Article/{entryDate}",
    new {controller = "Article", action = "Entry")};

我也试过以下

routes.MapPageRoute("Blog",
    "/Article/{month}.{Date}.{year}",
    new {controller = "Article", action = "Entry")};

但没有运气..

but no luck..

请指导我一些样本。

推荐答案

我认为问题是,IIS可能会处理0.2013​​作为文件扩展名,并试图找到一个处理程序。我们需要做的是让MVC过程中的所有请求。

I believe the issue is that IIS might be treating ".2013" as a file extension and trying to find a handler for it. What we need to do is to have MVC process all requests.

如果您在IIS 6这一点,你需要做一个通配符映射到 ASPNET_ISAPI.DLL 。如果你在IIS 7,您可以设置 runAllManagedModulesForAllRequests =真正的

If you are on IIS 6 this you will need to do a wildcard mapping to aspnet_isapi.dll. If you are on IIS 7 you can set the runAllManagedModulesForAllRequests="true":

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
    </modules>
</system.webServer> 

这篇关于URL模式路由MVC 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆