开发者

Asp.Net 4: How to route to a web form in an MVC site?

This question by Nick Craver implements routing to web forms like this:

routes.MapPageRoute("defaultRoute", "{*value}", "~/Missing.aspx");

However we get an error of Route data must contain an item named controller.

Is it possible to route to a web form?

We need to "catch" and route within routing rather than not hitting any routes then defaulting to the actual name. I don't think routing is specific to MVC, although we are routing开发者_运维知识库 to a web form that exists within an MVC site.


I think you will need to add an IgnoreRoute in your RegisterRoutes method.

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

This will tell MVC to not try to route this like it would normally. This is for .Net 4.0.

Here is some more details on this.

EDIT - SINCE MY INITIAL ABOVE ANSWER....

Scott Hanselman just created a nice post on integrating the two environments. Have a look at it. I imagine it is something in the initial setup of everything that may have been missed or not configured correctly that will be the culprit.


Although Routing was introduced with ASP.NET MVC its actually a separate mechanism. For your issue, are you entirely sure you are using MapPageRoute instead of MapRoute?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜