asp.net-mvc-routing

Unable to get webApi result in controller

纵然是瞬间 提交于 2020-08-11 18:49:28
问题 I am trying to create constraint for route.Based on the access info retrieved from Db,i will choose which route to choose. I have created controller inheriting IRouteConstraint and calling repository,but Unable to get result from httpclient call. Code snippet of my routeConfig routes.MapRoute( name: "Home", url: "{*routelink}", defaults: new { controller = "Home", action = "Index" }, constraints: new { routelink = new UserAccessController("Home") } ); routes.MapRoute( name: "Reports", url: "{

Unable to get webApi result in controller

梦想与她 提交于 2020-08-11 18:48:20
问题 I am trying to create constraint for route.Based on the access info retrieved from Db,i will choose which route to choose. I have created controller inheriting IRouteConstraint and calling repository,but Unable to get result from httpclient call. Code snippet of my routeConfig routes.MapRoute( name: "Home", url: "{*routelink}", defaults: new { controller = "Home", action = "Index" }, constraints: new { routelink = new UserAccessController("Home") } ); routes.MapRoute( name: "Reports", url: "{

Unable to get webApi result in controller

北城余情 提交于 2020-08-11 18:46:12
问题 I am trying to create constraint for route.Based on the access info retrieved from Db,i will choose which route to choose. I have created controller inheriting IRouteConstraint and calling repository,but Unable to get result from httpclient call. Code snippet of my routeConfig routes.MapRoute( name: "Home", url: "{*routelink}", defaults: new { controller = "Home", action = "Index" }, constraints: new { routelink = new UserAccessController("Home") } ); routes.MapRoute( name: "Reports", url: "{

Unable to get webApi result in controller

北慕城南 提交于 2020-08-11 18:46:09
问题 I am trying to create constraint for route.Based on the access info retrieved from Db,i will choose which route to choose. I have created controller inheriting IRouteConstraint and calling repository,but Unable to get result from httpclient call. Code snippet of my routeConfig routes.MapRoute( name: "Home", url: "{*routelink}", defaults: new { controller = "Home", action = "Index" }, constraints: new { routelink = new UserAccessController("Home") } ); routes.MapRoute( name: "Reports", url: "{

How to generate URL for the action with attribute routing in Asp.Net MVC

北战南征 提交于 2020-07-08 20:37:07
问题 public class HomeController : Controller { [Route("Users/about")] [Route("Users/WhoareWe")] [Route("Users/OurTeam")] [Route("Users/aboutCompany")] public ActionResult GotoAbout() { return View(); } } I have many routes defined for action GotoAbout() . How to create route URL in razor page programmatically when generate URL for action like home/users/about ? 回答1: Reference Attribute Routing in ASP.NET MVC 5 - Route Names You can specify a name for a route, in order to easily allow URI

How to generate URL for the action with attribute routing in Asp.Net MVC

一个人想着一个人 提交于 2020-07-08 20:36:59
问题 public class HomeController : Controller { [Route("Users/about")] [Route("Users/WhoareWe")] [Route("Users/OurTeam")] [Route("Users/aboutCompany")] public ActionResult GotoAbout() { return View(); } } I have many routes defined for action GotoAbout() . How to create route URL in razor page programmatically when generate URL for action like home/users/about ? 回答1: Reference Attribute Routing in ASP.NET MVC 5 - Route Names You can specify a name for a route, in order to easily allow URI

ASP.NET MVC Routing question

烈酒焚心 提交于 2020-06-17 04:24:32
问题 I have simple question about MVC routing. How i can construct Html.ActionLink thhat generates following link http://mysite.com/phones/samsung Now it's generates as http://mysite.com/phones/brand?brand=samsung Also i want to avoid mentioning action name in URL There is my code: Route: routes.MapRoute(null, "Phones/{brand}", new { controller = "Phones", action = "Index", brand = UrlParameter.Optional }); Controller: MySyteDBEntities ms = new MySyteDBEntities(); public ActionResult Index() {

ASP.NET MVC Routing question

泪湿孤枕 提交于 2020-06-17 04:23:05
问题 I have simple question about MVC routing. How i can construct Html.ActionLink thhat generates following link http://mysite.com/phones/samsung Now it's generates as http://mysite.com/phones/brand?brand=samsung Also i want to avoid mentioning action name in URL There is my code: Route: routes.MapRoute(null, "Phones/{brand}", new { controller = "Phones", action = "Index", brand = UrlParameter.Optional }); Controller: MySyteDBEntities ms = new MySyteDBEntities(); public ActionResult Index() {

Routing and GetVirtualPath problem

柔情痞子 提交于 2020-03-05 07:56:19
问题 I'm using MVC 2 Preview2, with two areas in a single project. When I use RouteTable.Routes.GetVirtualPath(this.viewContext.RequestContext, null) from inside an area, I got the virtual path to the first area instead. Except for this, areas are working pretty well. What can I doing wrong? 回答1: in MVC 2 use GetVirtualPathForArea instead of GetVirtualPath 来源: https://stackoverflow.com/questions/1627423/routing-and-getvirtualpath-problem