Questions tagged [asp.net-routing]

ASP.NET routing enables you to use URLs that do not have to map to specific files in a Web site in both ASP.NET MVC and ASP.NET Webforms.

ASP.NET routing enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.

You can define URL patterns that map to request-handler files, but that do not necessarily include the names of those files in the URL. In addition, you can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string. This topic requires an understanding of ASP.Net Routing and its design logic.

Adding Routes to Webforms

Adding Routes to an MVC Application

399 questions
2
votes
1 answer

How to call controller action with a routeValue parameter in ASP.NET MVC

I have existing code with below @html.RenderAction() method: Html.RenderAction("Widget", "Widget", new { wTitle = "World map dashboard", wTitleSpan = "", wTitleDisplay = "", height = "300px;", wAction = "GetWorldMapMethod", …
Brijraj
  • 177
  • 2
  • 3
  • 13
2
votes
4 answers

Unable to make ActionLink or RouteLink generate the correct URL

I'm new to ASP.NET MVC (working with version 3) and cannot get ActionLink or RouteLink to work as I'm expecting. In this app, an event can have many activities and I wish to route to them using: /Event/1/Activity /Event/1/Activity/Index (same as…
Alex Angas
  • 59,219
  • 41
  • 137
  • 210
2
votes
1 answer

Conditional ASP.NET MVC 3 Routing (With Areas)

Hurro. I'm trying to achieve some conditional routing based on whether the current user is an admin or not. The system only has two modes, admin or non-admin and nothing more than this. I'm using areas for my admin area because the controller…
Kieran Senior
  • 17,960
  • 26
  • 94
  • 138
2
votes
1 answer

ready to use uint route constraint?

I have a .NET Core Web API project and my Ids are integers starting at 1. In most samples I see something like this [HttpGet("{id:int}")] public async Task> GetUserByIdAsync([FromRoute] int id) { // ... } Since I know Ids…
Question3r
  • 2,166
  • 19
  • 100
  • 200
2
votes
2 answers

Ignore controller in ASP.NET Web API

Our team maintains a self-hosted ASP.NET Web API. The project uses attribute routing and we have dozens of existing controllers. Lets say, the API is exposed via the main path /api/purpose1/... with all the existing controllers being placed as…
mu88
  • 4,156
  • 1
  • 23
  • 47
2
votes
2 answers

Asp.net routing to mask out physical folder in path

To better organise my ASP.Net project I placed all my .aspx files in a folder called WebPages. I would like to find a way to mask out the 'WebPages' folder out from all my URLs. So for example, I do not want to use the following…
Hady
  • 2,597
  • 2
  • 29
  • 34
2
votes
2 answers

How to log the selected ASP.NET Core MVC route?

Is there a simple way to log (using nlog, e.g. log.Debug(…)) the selected route in an ASP.NET Core MVC application? I use HttpGet/HttpPost attributes to define my routes, and I am looking for a simple way to log the route that MVC chooses to handle…
shelbypereira
  • 2,097
  • 3
  • 27
  • 50
2
votes
1 answer

AsP.NET 4.0 url routing

I am trying the new feature of .NET 4.0 - url routing but not able to fetch information passed in the url. Following is the code : GLOBAL.ASPX.CS protected void Application_Start(object sender, EventArgs e) { …
Ankit
  • 6,388
  • 8
  • 54
  • 79
2
votes
3 answers

Url routing problem with IIS7

Url routing and IIS7 03-24-2011 04:24 PM Hi, I have a query regarding Url Routing in asp.net 4.0 and IIS7. Below I have explained what is my website structure and how it is configured in IIS7. Directory Structure: 1.MyWebsite>Index.aspx…
thinkmmk
  • 487
  • 1
  • 8
  • 22
2
votes
2 answers

ASP.net WebForms - Using GetRouteUrl in markup

I have been trying to figure out how to use the Routing features with ASP.net 4.0 WebForms. I added a route to my route collection: void Application_Start() { RegisterRoutes(RouteTable.Routes); } void RegisterRoutes(RouteCollection routes) { …
Dismissile
  • 32,564
  • 38
  • 174
  • 263
2
votes
1 answer

default route with id does not working in asp.net core

This is my controller: public class HomeController : Controller { public IActionResult Index() { var route = Request.Path.Value; return View("index" as object); } [HttpGet("{id}")] public IActionResult Index(int…
Ares
  • 23
  • 5
2
votes
1 answer

Aspnet greedy route parameter

I have mapped route: routes.MapRoute("test", "/{p1:int}-{p2}", new { controller = "test", action = "int" }); Such route should match int-string, like /1-stuff, and it works for such cases, however it does not work for /1-stuff-stuff. I guess this is…
Shadow
  • 2,089
  • 2
  • 23
  • 45
2
votes
1 answer

No route matches the supplied values RedirectToRoute

I have the following route set up [HttpGet("bar")] public IActionResult Foo() When I access the website with "/bar", I am directed to Foo, as expected. However, if I try to redirect to "bar", I get an error: public async Task
Dan Friedman
  • 4,941
  • 2
  • 41
  • 65
2
votes
0 answers

Differentiate angular 5 routes and server side routes

I am developing an angular 5 application with .NET core 2.0. I wanted to differentiate the angular 5 routes with hash tag (/#/home) and server side routes from .NET controllers with normal routing (/home). When I apply {usehash:true} in angular,…
Srini
  • 181
  • 1
  • 1
  • 6
2
votes
2 answers

Where is Url.Action getting these values from?

I'm trying to create a link to the following GET action with Url.Action: public class FooController : Controller { [HttpGet] [Route("Foo/Apply/BarDetails/Part/{id}")] public IActionResult BarDetails(int id) { } } And in my view…
Mourndark
  • 2,526
  • 5
  • 28
  • 52