Asp.Net MVC IgnoreRoute一个区域内 [英] Asp.Net MVC IgnoreRoute inside an Area

查看:78
本文介绍了Asp.Net MVC IgnoreRoute一个区域内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何忽视了一个区域内的路由?

How to ignore a route inside an area?

我的captcha在我的MVC application.It从GenericHanlder(ashx的)加载自己的形象。

I have captcha in my MVC application.It loads its image from an GenericHanlder(.ashx),so if imnot using areas it works fine, if I just ignore routes from that URL.

即:
在Global.asax中

i.e: In Global.asax

routes.IgnoreRoute(Counts/{filename}.{ashx}/{*pathinfo});//Counts is the controller name without an area

的问题是,最近我的文件迁移到不同的区域,是被忽略modified.Now路由的路径其

The problem is that recently I migrated the files to a different area and the path of the route to be ignored was modified.Now its:

Admin/Acounts/Users/captcha.ashx?guid=3565465689789hfghfdf

所以,我试图改变在Global.asax中的routes.IgnoreRoutes方法路径:

So i try to change that path in routes.IgnoreRoutes method in Global.asax:

routes.IgnoreRoute(Admin/Acounts/Users/{filename}.ashx/{*pathinfo});

但它不工作anymore.Ive已经尝试忽略RegisterArea方法途径,在AreaRegistrationFile:

But it doesnt work anymore.Ive already try to ignore that route in RegisterArea method,in AreaRegistrationFile:

    context.Routes.IgnoreRoute("Admin/Accounts/Users/{filename}.ashx/{*pathinfo}");

但也doenst工作。

But that also doenst work.

任何想法如何routesto一个区域忽视?

Any ideas how to ignore routesto an Area?

推荐答案

IgnoreRoute实际上只是调用加入(新干线()),使用路径的RouteHandler参数设置为是一个新的StopRoutingHandler。该StopRoutingHandler告诉URL路由模块忽略路线,并不管下一个内联的HttpHandler会。

IgnoreRoute is really just a call to Add(new Route()), with the RouteHandler parameter of the Route set to be a new StopRoutingHandler. The StopRoutingHandler tells the URL routing module to ignore the route and get whatever the next-inline HttpHandler would be.

您知道这条路线注册是声明的顺序敏感。我的猜测是,你可以声明你IgnoreRoute后,其他一些航线已经抓住了它。

You know that route registration is sensitive to the order of declaration. My guess is that you are declaring your IgnoreRoute after some other route already catches it.

如果信息的此位不帮你,请发表你的路线注册的全部内容,因为它们将帮助我们给你解答。

If this bit of info doesn't help you, please post the full contents of your route registration as they will help us to give you answers.

另外,如果你在使用的 http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx 用于调试的路线,它会更容易找到你的问题的原因。

Also, if you use the source code provided at http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx for debugging routes, it will be much easier to find the cause of your problem.

这篇关于Asp.Net MVC IgnoreRoute一个区域内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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