如何绘制传统的ASP请求到MVC控制器和操作 [英] How to map a classic asp request to an mvc controller and action

查看:144
本文介绍了如何绘制传统的ASP请求到MVC控制器和操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果说路由是不是我的浴室是轻描淡写,所以请多多包涵。

To say that routing is not my strong suite is an understatement, so please bear with me.

我在我的网页之一这个环节,我需要我的MVC路线选择这和其映射到

I have this link in one of my pages and I need my MVC route to pick this up and map it to the

MyArea区域
MessagesController控制器
收件箱方法

"MyArea" area "MessagesController" controller "Inbox" method

http://localhost/MyArea/messages/list.asp?pjid=&box=in&sf=mesibox

我想出迄今不剪。

What I've come up with so far does not cut it.

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

routes.IgnoreRoute("favicon.ico");

routes.MapRoute(
    "Messages", 
    "messages/list.asp", 
    new
        {
            controller = "Messages", 
            action = "Inbox"
        });

routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new
        {
            controller = "Account",
            action = "LogOn",
            id = UrlParameter.Optional
        }
    );

任何帮助将是AP preciated。

Any help would be appreciated.

感谢您,
斯蒂芬

Thank you, Stephen

更新:
达林在这里回答了类似的问题<一href=\"http://stackoverflow.com/questions/5278917/how-to-route-legacy-querystring-parameters-in-asp-net-mvc-3/5278949#5278949\">How在ASP.Net MVC 3路线遗留查询字符串参数?这样照顾查询字符串参数。现在要弄清楚的主要部分。

UPDATE: Darin answered a similar question here How to route legacy QueryString parameters in ASP.Net MVC 3? so that takes care of the query string parameters. Now to figure out the main segments.

推荐答案

您似乎已经定义的区域,所以这个区域,你可能尝试添加这条路线,而不是内部的Global.asax的路由配置里面:

You seem to have defined an area, so it is inside the routing configuration of this area that you may try adding that route and not inside global.asax:

public override void RegisterArea(AreaRegistrationContext context)
{
    context.MapRoute(
        "MyArea_default",
        "MyArea/messages/list.asp",
        new { controller = "messages", action = "inbox" }
    );

    context.MapRoute(
        "MyArea_default",
        "MyArea/{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional }
    );
}

这篇关于如何绘制传统的ASP请求到MVC控制器和操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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