asp.net-mvc-routing

When does routing take place in the pipeline?

故事扮演 提交于 2019-12-10 18:04:45
问题 When does routing take place in the ASP.NET MVC pipeline? ASP.NET Application Life Cycle Overview for IIS 7.0 Is it in step number 2 (Perform Url Mapping)? I intend to have a few routes that have an id "activate/{id}" "forgotpassword/{id}" I would like to be able to access the id early on in the pipline in step 4 - AuthenticateRequest. So that I can pass an authentication token through the id part of the url to my custom authentication module. So can I access the id property in my custom

How to make routelink return the correct URL?

有些话、适合烂在心里 提交于 2019-12-10 17:41:29
问题 here is the procedure to duplicate the issue. start new mvc 4 project. add the following lines to the RegisterRoutes() method just before the "Default" route routes.MapRoute( name: "Test", url: "Test/{action}", defaults: new { controller = "Test", action = "Index" } ); add the following to Index.cshtml and About.cshtml @Html.RouteLink("link to TestController", "Test") As you can see that the generated html code is different for the 2 pages. I would expect the URL is "/Test" which is rendered

ASP.net MVC route parameter exception

﹥>﹥吖頭↗ 提交于 2019-12-10 17:35:24
问题 I have and action which takes a userId parameter: ~/Users/Show?userId=1234 Everything works fine except when the userId provided is not an int or is missing. Then it throws this exception: Message: The parameters dictionary contains a null entry for parameter 'userId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Show(Int32, System.Nullable`1[System.Boolean], System.String)' in 'S4U.Web.Mvc.Controllers.ProfileController'. An optional parameter must be a reference

How to Hide Parameters of URL in MVC4

為{幸葍}努か 提交于 2019-12-10 17:12:24
问题 http://localhost:49397/ChildCare/SponsorChild/83 This is the Link ,which is being generated when i click on action link in table and redirecting to Edit Action, now i want to Hide the number '83' in the URL how can i acheive this, i am using VS2010 MVc4 Razor, Sorry for my bad engllish thanks in advance 回答1: if you work with links, the links send by GET request to the server, then the parameters are in the url. Might you have two options: 1 - the parameters would have to be on data attributes

c# mvc how to map the root url to a specific view

╄→гoц情女王★ 提交于 2019-12-10 17:09:53
问题 I have an mvc app with a DefaultController which maps to index.cshtml so http://localhost:<port>/Default/Index works fine. but the default root page: http://localhost:<port>/ is not mapped to anything. How can I map it to my Default/Index? Here is my RouteConfig.cs: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace MVC5_HttpClientTest_F45 { public class RouteConfig { public static void RegisterRoutes

MVC4: url routing with email as parameter

泪湿孤枕 提交于 2019-12-10 16:57:59
问题 I have this url which works absolutely fine on my VS web server http://localhost:4454/cms/account/edituser/email@domain.com (works) but when I publish this site to IIS7.5 , it simply throws 404. http://dev.test.com/cms/account/edituser/email@domian.com (does not work) but the strange things happens if I remove email address http://dev.test.com/cms/account/edituser/email (works , no 404) but if I change my url with query string it works fine http://dev.test.com/cms/account/edituser?id=email

WebAPI 2 Attribute routing with areas not working

主宰稳场 提交于 2019-12-10 16:47:36
问题 I'm having trouble getting WEBAPI 2 attribute routing to work. The routing scheme I'm looking for is /api/{product}/{controller}/{id-optional} , so like /api/Vision/IdCard . The controllers are in an area and are set up like this: namespace DataServices.Controllers.Vision { [RoutePrefix("api/vision")] public class IdCardController : BaseApiController { [System.Web.Mvc.RequireHttps] [Route("idcard")] public IdCardViewModel Get(HttpRequestMessage request) {...} Whenever I do a get to this, I

Using WebAPI Route attribute

心不动则不痛 提交于 2019-12-10 16:29:14
问题 I've got a few methods, which I want to follow a specific pattern for their URLs. Basically there's restaurants, which have IDs, and a collection of Terminals under them. I'm trying to get the following sort of pattern to emerge: api/Restaurant - get all Restaurants api/Restaurant/Bobs - gets the restaurant with the ID of Bobs api/Restaurant/Bobs/terminals - get all terminals in bobs restaurant api/Restaurant/bobs/terminals/second - get the terminal with the ID of second in the restaurant bob

MVC Preview 4 - No route in the route table matches the supplied values

邮差的信 提交于 2019-12-10 15:16:50
问题 I have a route that I am calling through a RedirectToRoute like this: return this.RedirectToRoute("Super-SuperRoute", new { year = selectedYear }); I have also tried: return this.RedirectToRoute("Super-SuperRoute", new { controller = "Super", action = "SuperRoute", id = "RouteTopic", year = selectedYear }); The route in the global.asax is like this: routes.MapRoute( "Super-SuperRoute", // Route name "Super.mvc/SuperRoute/{year}", // URL with parameters new { controller = "Super", action =

Routing a custom controller in Orchard CMS

天大地大妈咪最大 提交于 2019-12-10 14:55:51
问题 I'm having some trouble setting up the routing to a custom controller in Orchard. I've created a View: @model dynamic @{ Script.Require("jQuery"); } @using (Html.BeginForm("Send", "Email", FormMethod.Post, new { id = "contactUsForm" })) { <fieldset> <legend>Contact Us</legend> <div class="editor-label">Name:</div> <div class="editor-field"> @Html.TextBox("Name", "", new {style = "width: 200px"}) </div> <div class="editor-label">Email Address:</div> <div class="editor-field"> @Html.TextBox(