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
6
votes
4 answers

How to route tree-structured URLs with ASP.NET Routing?

I would like to achieve something very similar to this question, with some enhancements. There is an ASP.NET MVC web application. I have a tree of entities. For example, a Page class which has a property called Children, which is of type…
Venemo
  • 18,515
  • 13
  • 84
  • 125
6
votes
2 answers

Optional route parameters in ASP.NET 4 RTM no longer work as before

I upgraded my project to ASP.NET 4 RTM with ASP.NET MVC 2.0 RTM today. I was previously using ASP.NET 3.5 with ASP.NET MVC 2.0 RTM. Some of my routes don't work suddenly and I don't know why. I'm not sure if something changed between 3.5 and 4.0 -…
Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689
6
votes
1 answer

Asp.net MVC/Web Api Routing: Need to route a little different

I have setup a asp.net web api project (it works exactly the same as a Mvc Project) using routing - hence i have the following routes.MapHttpRoute( name: "API Default", routeTemplate: "api/{controller}/{id}", defaults: new { id =…
Martin
  • 23,844
  • 55
  • 201
  • 327
6
votes
1 answer

What is wrong with this Global.asax routing setting?

I maybe expecting too much from ASP.NET, but in Apache it's trivial to rewrite urls so requesting something like: http://mysite/myfolder/mypage/niceurlparameter actually manages to serve static page http://mysite/mypage.html How do I do that in…
tishma
  • 1,855
  • 1
  • 21
  • 43
5
votes
1 answer

ASP.NET Core 2 default route having areas

cI went through various posts regarding the Areas routing but still I am not able to resolve my issue. I would like to split my application in the way that there are two routes. /Areas/Panel /Areas/Website Inside each area there is…
Greg Wozniak
  • 5,209
  • 3
  • 26
  • 29
5
votes
0 answers

Is there an equivalent to routes.IgnoreRoute(...) in ASP.NET CORE?

In ASP.NET MVC 4, I could ignore certain routes by using: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{*old}", new {old=@"previous(/.*)?"}); } .NET Core doesn't have IgnoreRoute. Is there a way to achieve…
5
votes
1 answer

Manipulate the url using routing

In my website I have the following route defined: routes.MapRoute( name: "Specific Product", url: "product/{id}", defaults: new { controller = "", action = "Index", id = UrlParameter.Optional } ); In that way I want customers to be able to…
Giannis Paraskevopoulos
  • 18,261
  • 1
  • 49
  • 69
5
votes
1 answer

ASP.NET MVC model nesting routes

Consider an ASP.NET MVC application with two models: let's say Company and Person. Each company has a list of persons. Each person belongs to one company only. If you set up the model and use Visual Studio to generate the controllers/views, you get…
ian93
  • 1,488
  • 4
  • 24
  • 37
5
votes
2 answers

How does asp.net mvc figure it out?

How is it that I can create a method in the controller and just put some arguments and it figures it out after I click on a form submit? Under the hood, how does it find the right method and how does it figure out that I just want those arguments?
leora
  • 188,729
  • 360
  • 878
  • 1,366
5
votes
3 answers

Routing to virtual item

I am trying to create a route in route table that routes to a virtual item (using a cms that creates url like example.com/about/company, where there is no physical file called company exists) using system.web.routing (unfortunately i cannot use iis…
xoail
  • 2,978
  • 5
  • 36
  • 70
5
votes
2 answers

Invoke ASP.NET MVC Controller When Requesting .html file

I need to add some new life to a legacy application :) I'd like to call an MVC controller when a "static" HTML page is requested in order to add some markup to the page before returning it to the client. I tried to follow the approach found in this…
Craig Shoemaker
  • 245
  • 3
  • 17
4
votes
2 answers

How do I programatically list all routes in .NET Core Web API project?

I have an ASP.NET Core 5 Web API where routes are not matched. It works fine locally, but it's not working on the server. The logs show me No candidates found for the request path but I see the request path and it is correct. I would like to log…
Don Chambers
  • 3,798
  • 9
  • 33
  • 74
4
votes
2 answers

A word that do so the ASP.NET (MVC) Routing crashes

I read about a string/word that did so the Routing crashed but I can't remember which word/string combination it was. Example: Microsoft Logging application block and multi-threading - works Microsoft Logging application block and multi-threading -…
Yesman
4
votes
1 answer

NET Core 5 How to override an action on a controller

Let's imagine I have a "platform" with some basic features. It has its own set of controllers with actions delivered as a class library. For example, let's name it as CartController with Order action, as a result, API URL will be Cart/Order. For…
4
votes
1 answer

ASP.NET Routing - GetRouteData does not work if path exists

I have a HttpModule which intercepts all requests and loads data from the database based on routing rules. However, I run into one problem all the time; GetRouteData only works if the path does not exist: var routeData =…
Alfero Chingono
  • 2,663
  • 3
  • 33
  • 54
1 2
3
26 27