maproute

MVC ASP.NET Map routing is not working with form GET request

一曲冷凌霜 提交于 2019-12-11 04:16:44
问题 In View- @using (Html.BeginForm("PageName","ControllerName", FormMethod.Get)) { <input type="hidden" name="categoryName" value="Insurance" /> <input type="hidden" id="cityName6" value="Irvine" name="cityName" /> <input type="hidden" name="page" value="1" /> <input type="submit" class="btn btn-default" value="Insurance" /> } In RouteConfig- routes.MapRoute( "SomethingRouteName", "{categoryName}/{cityName}/{page}", new { controller = "ControllerName", action = "PageName" } ); I want url to

Map route asp.net mvc

走远了吗. 提交于 2019-12-08 05:58:02
问题 I'm trying to make my url seo friendly. I need to make url with this structure www.domainname.com/article123. And with this route routes.MapRoute( "articlename", // Route name "aaaa/{articleID}", // URL with parameters new {action="DetailsByName",controller="Article"}, new string[] { "bssnew.Controllers" } // Parameter defaults); It doesn't work. MY route link looks like this @Html.RouteLink("aaa ","articlename", new {articleID="CentralPark",},new { @class = "item-link" }) But when I add

How to use Routing in MVC for SEO Friendly URL

百般思念 提交于 2019-12-08 01:24:01
问题 Generally we have following sample code in our global.asax file. So, my question is how we can have multiple MapRoute and how to use them ??? I want URL like: http://domain/Home.aspx/Index/Cricket-Ball/12 public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } I want something like this, but i don't

Asp.net MVC and redirect to External site

时光毁灭记忆、已成空白 提交于 2019-12-07 10:00:26
I have created a mvc application, its working fine, now I want to add some route based on xml, I don't want to create action based on that, that will work on fly. i.e. www.lmenaria.com/site1 this will redirect to www.site1.com www.lmenaria.com/site2 this will redirect to www.site2.com www.lmenaria.com/site3... this will redirect to www.site3.com No action Site1, site2, site3 lmenaric.om, so what will be the route and how can I redirect to external site. You can do this on controller with only one action but you need a route constraint for that o/w you will end up routing all the request to the

MVC routing static file

这一生的挚爱 提交于 2019-12-05 09:27:46
I am working with a legacy swf file that is looking in the controller/action routing for a static route. For example, it is trying to download the file http://localhost:59801/Resource/Details/ClearExternalPlaySeekMute.swf When the file exists in the root directory: http://localhost:59801/ClearExternalPlaySeekMute.swf Can I use MapRoute to map this URL to the root directory? You could use the url rewrite module in IIS. Once you install it simply add the following rewrite rule: <system.webServer> <rewrite> <rules> <rule name="Rewrite Static Flash file" stopProcessing="true"> <match url="

Custom objects as arguments in controller methods defined by MapRoutes

蓝咒 提交于 2019-12-04 16:01:28
问题 Consider this MapRoute: MapRoute( "ResultFormat", "{controller}/{action}/{id}.{resultFormat}", new { controller = "Home", action = "Index", id = 0, resultFormat = "json" } ); And it's controller method: public ActionResult Index(Int32 id, String resultFormat) { var dc = new Models.DataContext(); var messages = from m in dc.Messages where m.MessageId == id select m; if (resultFormat == "json") { return Json(messages, JsonRequestBehavior.AllowGet); // case 2 } else { return View(messages); //

Custom objects as arguments in controller methods defined by MapRoutes

若如初见. 提交于 2019-12-03 09:10:51
Consider this MapRoute: MapRoute( "ResultFormat", "{controller}/{action}/{id}.{resultFormat}", new { controller = "Home", action = "Index", id = 0, resultFormat = "json" } ); And it's controller method: public ActionResult Index(Int32 id, String resultFormat) { var dc = new Models.DataContext(); var messages = from m in dc.Messages where m.MessageId == id select m; if (resultFormat == "json") { return Json(messages, JsonRequestBehavior.AllowGet); // case 2 } else { return View(messages); // case 1 } } Here's the URL scenarios Home/Index/1 will go to case 1 Home/Index/1.html will go to case 1