开发者

routing to a webform using MVC routing

I have a MVC 2 project runnin in .net 3.5. There are some Webforms which i have in a separate folder called "Forms". I need to routing to be i开发者_如何学运维mplemented for this page. Like, localhost/home.aspx should be re-directed to localhost/Forms/home.aspx. When i tried using the following code,

routes.MapRoute(
            "Default", // Route name
            "home.aspx",  // URL with parameters
            @"Forms/Home.aspx"// Parameter defaults
        );

I get an error saying,

The RouteData must contain an item named 'controller'

I tried this link, but when i try to implement

routes.MapPageRoute("ReportRoute",                         // Route name
 "Reports/{reportname}",                // URL
 "~/CommonReports/{reportname}.aspx"   // File
 );`

Iam not getting the MapPageRoute() method in my routes object. Could some one helpme how to handle this? Thanks in Advance


MapPageRoute() was only introduced in .Net 4 - which is why it is not available. There is an article about using a custom route handler that implements IRouteHandler at http://msdn.microsoft.com/en-us/library/cc668202%28v=vs.90%29.aspx which should do what you want.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜