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
9
votes
1 answer

Direct different IP's to different pages on IIS7

Using IIS7, how do I direct internal private network IP's addresses to my web site while I direct external IP addresses to a "site under maintenance" page? So far on IIS7 I've found the section in IIS named "IPv4 Address and Domain Restrictions" and…
Guy
  • 65,082
  • 97
  • 254
  • 325
9
votes
1 answer

Advanced ASP Routing tutorials and examples

One of major hurdles I seem to be having recently is getting my head around some of the more complex routing requirements for some MVC based applications I've been developing. I'm having problems finding the right set of tutorials to walk me through…
Kieron
  • 26,748
  • 16
  • 78
  • 122
9
votes
2 answers

ASP.NET MVC 5 - (HTTP Error 404.0 - Not Found) with long non-existing URL

I created a new project in Microsoft Visual Studio Express 2013 for Web. It is an ASP.NET MVC 5 - .NET Framework 4.5 project. I wanted to handle (The resource cannot be found): I did handle it using the code below. This code will work if I do…
NewUser_
  • 331
  • 1
  • 2
  • 9
8
votes
1 answer

Multiple RoutePrefixes per controller using MVC Attribute routing?

With the new MVC Attribute routing, I know you can assign multiple Route attributes to a single ActionResult, but I am looking for a way to do the same at the RoutePrefix level. I have a controller which, in every action, should be accessible by…
Matthew Verstraete
  • 6,335
  • 22
  • 67
  • 123
8
votes
1 answer

Physical Folder Breaks ASP.NET URL Routing on IIS Express

IIS Express is producing 403.14 Forbidden errors when a URL that would otherwise be handled through ASP.NET URL routing happens to correspond to a physical folder in my ASP.NET project. (The folder contains only code, and it's coincidental that the…
Ian Griffiths
  • 14,302
  • 2
  • 64
  • 88
7
votes
1 answer

Decode string with plus sign

Using ASP.NET Core I am receiving the following token (simplified): String token = "Z%2F3+3Q=="; The / is encoded using %2F. I received the token from a URL called on the client using Angular. I tried to decode the token using the…
Miguel Moura
  • 36,732
  • 85
  • 259
  • 481
7
votes
1 answer

Get Route Values in Razor Pages

I want to know how can I get the route values in Razor Pages (Page.cshtml). Ex. https://localhost:44320/AdminPanel/Admins if I was using MVC i would get these datas as var controller = ViewContext.RouteData.Values["Controller"]; //AdminPanel var…
7
votes
5 answers

How do I route images through ASP.NET routing?

I'd like to create a dynamic thumbnail resizer so that you can use the following URL to get a resized image: http://server/images/image.jpg?width=320&height=240 I tried setting up a route like this: routes.MapRoute(null, …
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
7
votes
1 answer

Do WebApi 2 and MVC 5 user different routing attributes?

Reading through this blog post on attribute routing in ASP.NET MVC 5 and this one on attribute routing in Web Api 2, it looks like there are two sets of routing attributes, one in the System.Web.Mvc namespace and the other in System.Web.Http. Is…
Roman
  • 19,581
  • 6
  • 68
  • 84
7
votes
1 answer

ASP.NET MVC: How to force all links to goto 1 page?

I am trying to figure out how i can create a route configuration so that all URLS will goto the same VIEW (Page). CUrrently of course if i do for example /Products/Id Then this would look in the Products controller. I would like to always goto my…
Martin
  • 23,844
  • 55
  • 201
  • 327
6
votes
2 answers

Why is this route parameter tacked onto the querystring?

I have an ASP.NET MVC 3 application that records a user's pedometer entries. A user can view all most recent pedometer entries by visiting /Pedometer and can filter by year, year/month, or year/month/date by visiting URLs like /Pedometer/2011,…
Scott Mitchell
  • 8,659
  • 3
  • 55
  • 71
6
votes
1 answer

Redirect to another controller+ action without changing URL in ASP.Net MVC3

Note: Below is just a small demo sort to simulate what i am looking for: Below are the urls format on my app that user can see mydomain.com/cat/1 --display cat with id 1 |controller=Cat, action=DisplayDetails mydomain.com/dog/2 --display dog with…
Praveen Prasad
  • 31,561
  • 18
  • 73
  • 106
6
votes
2 answers

How do I redirect a route to another route in ASP.NET web forms?

I have routes like these: routes.MapPageRoute("Survey", "Survey", "~/Survey/Survey.aspx") routes.MapPageRoute("Letters", "About/Letters", "~/Pages/Letters/Letters.aspx") How can I redirect a url like this: /Surveys to the 'Survey' route? So that…
StrattonL
  • 708
  • 1
  • 9
  • 24
6
votes
0 answers

WebApi and MVC Routing not working on Server 2012 IIS 8.5 (404.0 Error)

I have an application using .NET Framework 4.7.1 with WebAPI and MVC routes defined in it. They both work when debugging locally with IISExpress, but when I deploy to the Development server (Windows Server 2012R2 with IIS 8.5), all I get is a 404.0…
6
votes
2 answers

Make ASP.NET MVC Route Id parameter required

I have this route: routes.MapRoute( "PlaceDetails", "{controller}/{action}/{id}", new { controller = "Place", action = "Details", id = UrlParameter.Optional } ); This routes this…
niico
  • 11,206
  • 23
  • 78
  • 161
1
2
3
26 27