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
3
votes
2 answers

system.web.routing on a web server not working

I have read all these articles about how to make system.web.routing work but all these articles explains on localhost:port. I can get this working on the local machine, but as soon as I upload the site on the server, the Routing stops working no…
Kin
3
votes
2 answers

How do I get ASP.NET WebForms Routing to route .asmx JSON calls properly?

I am attempting to implement multi-tenancy in a legacy ASP.NET WebForms app. I want the URL to indicate the proper client, like so: http://example.com/client_name/Default.aspx http://example.com/client_name/MyWebService.asmx However, I cannot get…
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177
3
votes
1 answer

Alternative to routes.IgnoreRoute in Web Forms

I use asp.net c# using Web Forms. I use Routing for my website. I need my Route ignore ELMAH (myFolder/elmah.axd) I was thinking to use routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); But IgnoreRoute is from System.Web.Mvc namescape so I cannot…
GibboK
  • 71,848
  • 143
  • 435
  • 658
3
votes
0 answers

OData 8 - Custom routing with named parameters that do not care about order

In the .NET Framework 4.8 version of the API I'm working on, I could specify the routing to an endpoint as so: [ODataRoute("/myEndpoint(FirstName={firstName},LastName={lastName})/Data")] This would accept queries regardless of their named parameter…
3
votes
2 answers

Web Form Routing - Cannot create an abstract class

Net 3.5 SP1 and attempting to implement a sample copy of http://haacked.com/archive/2008/03/11/using-routing-with-webforms.aspx into a sample web application however I seem to be having some issues. I am running windows vista, IIS 7.0,…
Daniel
3
votes
1 answer

Razor Page Redirect to Razor Component

I have the following setup in my project: /Pages/Page1.razor /Pages/Page2.cshtml Page 1 is a Blazor component. Page 2 is a Razor Page. At the top of Page1: @page "/Page1" In the Page2.cshtml.cs code-behind I have: public IActionResult…
3
votes
2 answers

Web API 2 Attribute Routing for API Versioning

I have an ASP.NET Web API 2 application which uses convention-based routing: [app-url]/v1/[controller] Now, I want to add another version to the API, and found that attribute routing is the easiest way to achieve what I want. Therefore, I…
Fusyoo
  • 39
  • 2
  • 8
3
votes
1 answer

Is is possible to make SEO friendly Url's in ASP.NET Core like this one

I wanted to ask you guys if is it possible, to make some routing like this for my project /{action}/{title}? I was wondering if that is possible, does this url has to be a primary key too? Since there is no ID passed to know which blog post is…
3
votes
1 answer

Web Api Controller Routes Randomly Stop Working

I have an ApiController called MediaController, with routes mapped to methods via the [Route] attribute. For example: [Route("v1/libraries/{libraryKey}/media"), HttpGet] public ResponseObj Index(string libraryKey) { ... } These routes are…
sds6065
  • 195
  • 1
  • 8
3
votes
1 answer

How to route lower-case URLs ('questions/add_to_favorites/123') with underscores in ASP.NET MVC2?

ASP.NET MVC 2 controllers and actions use UpperCamelCase. For some reasons many big sites, including SO, use lowercase (with underscore) for controllers and actions in the urls.…
randomguy
  • 12,042
  • 16
  • 71
  • 101
3
votes
2 answers

ASP.NET MVC Route Default values

i defined two routes in global.asax like below context.MapRoute("HomeRedirect", "", new { controller = "Home", action =…
Sadegh
  • 4,181
  • 9
  • 45
  • 78
3
votes
2 answers

Area routing in ASP.NET MVC

I am a bit confused with the area routing. I created an area called Backbone. I have my default controller, views and models as well. http://localhost:46870/ gives me the following error : Multiple types were found that match the controller named…
Sumesh Kuttan
  • 1,333
  • 1
  • 17
  • 40
3
votes
1 answer

Route VS RouteBase

The question is quite straightforward: When we mention about implementing a custom Route Handler, when to derive from Route, and when from RouteBase ? Some possible scenarios: SubdomainRouting Include localization in URL Custom GetVirtualPath…
Cristian E.
  • 3,116
  • 7
  • 31
  • 61
3
votes
1 answer

ASP.NET Routing - How to respond 404 for .aspx requests

I am using routing in webforms to clean up urls. I store all my .aspx files in the /Pages directory and route to them with clean URLs. As it stands I can still access these files by navigating to /Pages/Home.aspx for example. How can I either throw…
Zerkey
  • 795
  • 1
  • 6
  • 16
3
votes
1 answer

Ajax Url to Routed WCF in Asp.Net 4 Web Forms

I implemented Routing in Asp.Net 4 Web App. With aspx file it works fine, but it doesn't work with WCF. I have WCF which is called from javascipt file by ajax request. My WCF code is: [ServiceContract(Namespace = "")] …
Sasha.M
  • 77
  • 1
  • 7