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

ASP.NET Core Nested / Tiered Controllers

Hi there fellow Overflowing Stackers! Looking for your help in regards to having tiered or nested controllers in asp.net core So far from what I can see, the default boilerplate code, and its default route {controller=Home}/{action=Index}/{id?} only…
4
votes
0 answers

ASP Core - Localized Routes not respected by Url.Action

I implemented localized routes using a ApplicationModelConvention. This works fine as long as I type the urls directly in the browser. So for example german routes are only expected in german culture. and routes from other languages are returning a…
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
4
votes
1 answer

GetVirtualPath returns the first route

Got a strange problem with my project routes. Here are my routes: // pennames routes.MapRoute( "pennames", // Route name "MyHome/Authors/{action}/{id}", // URL with parameters new { controller…
user568385
  • 51
  • 3
4
votes
1 answer

How do I configure routing for MVC and SignalR in an ASP.NET Core project?

I'm trying to build a web app with ASP.NET Core 2.1.0-preview1 and ASP.NET Core SignalR 1.0.0-alpha1 with an Angular4 client. So far I've been able to muddle through and can actually open a SignalR web socket connection from within the client. That…
Thorsten Westheider
  • 10,572
  • 14
  • 55
  • 97
4
votes
2 answers

Can I add route for controller with parameters?

Can I use route attribute for controller and the attribute has parameters, not only constant string in ASP.NET Core? ex. I want add undermentioned definition controller [Route("api/sth/{Id}/sth2/latest/sth3")] public class MyController :…
Art Base
  • 1,739
  • 3
  • 15
  • 23
4
votes
3 answers

Change Controller and Action name according to language selected

I have a Controller with the name "Hem" and Action name is "Om". And default language i have set Swedish. So route will be on Swedish site, it's /sv/Hem/Om Now I want to change language to "en" by clicking English in language section. So route will…
4
votes
2 answers

How to create RouteUrls with databound parameters declaratively?

I'm using the new Routing feature in ASP.NET 4 (Web forms, not MVC). Now I have an asp:ListView which is bound to a datasource. One of the properties is a ClientID which I want to use to link from the ListView items to another page. In global.asax I…
Slauma
  • 175,098
  • 59
  • 401
  • 420
4
votes
2 answers

ASP.NET MVC: Html.Actionlink() generates empty link

Okay i'm experiencing some problems with the actionlink htmlhelper. I have some complicated routing as follows: routes.MapRoute("Groep_Dashboard_Route", // Route name "{EventName}/{GroupID}/Dashboard", // url with…
user323395
4
votes
2 answers

Scrambling URLS for dynamic data

What is the best method to obfuscate the urls created in Dynamic Data? eg \Products\List.aspx?ProductId=2 could become \Products\List.aspx?x=UHJvZHVjdElkPTI= where "ProductId=2" is base 64 encoded to prevent casual snooping on…
4
votes
1 answer

WebApi - REST & RPC combined

I have done quite a lot of research into ASP.NET Web API - having a RESTful, verb-based approach as well as having a RPC, traditional approach like on ASP.NET MVC together. I am wondering what the neatest approach would be. So far I have found two…
Adam Marshall
  • 3,010
  • 9
  • 42
  • 80
4
votes
1 answer

ASP.NET MVC: Routing hierarchy URL

How can I make routing for this? URL: /category/main/sub/ or /category/main/sub1/subsub/ I want to have /main/sub/ and /main/sub1/subsub/ as parameters in Index action method of CategoryController.
alexey
  • 8,360
  • 14
  • 70
  • 102
4
votes
2 answers

"True" REST routing via MVC 4 Web API

TL;DR Summary: Can I configure MVC Web API routing for HTTP GET, PUT & DELETE? I've been looking into replacing our old Data Access Layer (a DLL based on DataSets and TableAdapters) with a private API, with a view to creating a public API if it's…
Richard A.
  • 1,157
  • 1
  • 7
  • 18
4
votes
1 answer

MVC4 - route values not being remembered

Here's my route setup: routes.MapRoute( name: "MyRoute", url: "Secret/{source}/{display}/{sort}/{tags}/{filter}/{pageSize}/{page}", defaults: new { controller = "Secret", action = "Index", page = 1, filter = "-", tags = "-" }, …
Kieren Johnstone
  • 41,277
  • 16
  • 94
  • 144
4
votes
2 answers

Setting asp.net MVC4 web api route url in javascript is returning empty string

Here is the code that I am using to set the api url: var clientUrl = '@Url.RouteUrl("ApiControllerAction", new { httproute="", controller = "Client"})'; In my route.config the route looks like this: routes.MapHttpRoute( name:…
ledgeJumper
  • 3,560
  • 14
  • 45
  • 92
4
votes
1 answer

Difference between RouteTable.Routes and HttpConfiguration.Routes?

I am wondering why routes seem to be configurable from both the HttpConfiguration object and the RouteTable class? Clearly the two .Routes properties are not of the same type, but they seem to stay in-sync. Is there a chance they could get…
Jordan0Day
  • 1,386
  • 4
  • 15
  • 25