ASP.NET MVC 3路由

编程入门 行业动态 更新时间:2024-10-27 00:23:19
本文介绍了ASP.NET MVC 3路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想创建航线。

这是

/emlak/TITLE/number.aspx

/emlak/Here_is_your_best_property/123456.aspx

Global.asax中:

Global.asax:

routes.MapRoute( "Product", "{controller}/{deli}/{productId}", new { controller = "emlak", action = "Index" }, new { productId = UrlParameter.Optional , deli = UrlParameter.Optional } );

我控制器

namespace emrex.Controllers { public class EmlakController : Controller { // // GET: /Emlak/ public ActionResult Index(String productId, String deli) { return View(); } } }

和我得到一个错误:

在/应用程序中的服务器错误。

Server Error in '/' Application.

资源无法找到。

感谢您的帮助。

推荐答案

您的问题是(至少当我想你的code)你有指定的路由约束,他们真的不应该。我能得到这个通过做工作得很好:

Your problem is (at least when I tried your code) you have route constraints specified where they really shouldn't be. I was able to get this to work just fine by doing:

routes.MapRoute( "Product", "{controller}/{deli}/{productId}", new { controller = "emlak", action = "Index", productId = UrlParameter.Optional, deli = UrlParameter.Optional } );

尝试 - ?有什么区别

Try that - any difference?

更多推荐

ASP.NET MVC 3路由

本文发布于:2023-11-12 13:46:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581666.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   ASP   NET   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!