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

How to redirect to a dynamic login URL in ASP.NET MVC

I'm creating a multi-tenancy web site which hosts pages for clients. The first segment of the URL will be a string which identifies the client, defined in Global.asax using the following URL routing…
72
votes
7 answers

ASP.NET MVC, Url Routing: Maximum Path (URL) Length

The Scenario I have an application where we took the good old query string URL structure: ?x=1&y=2&z=3&a=4&b=5&c=6 and changed it into a path structure: /x/1/y/2/z/3/a/4/b/5/c/6 We're using ASP.NET MVC and (naturally) ASP.NET routing. The…
Martin Suchanek
  • 3,006
  • 6
  • 31
  • 31
43
votes
2 answers

Api controller declaring more than one Get statement

Using the new Api Controller in MVC4, and I've found a problem. If I have the following methods: public IEnumberable GetAll() public IEnumberable GetSpecific(int i) This will work. However, if I want to retrieve some different data…
Neil Knight
  • 47,437
  • 25
  • 129
  • 188
29
votes
5 answers

Can ASP.NET Routing be used to create "clean" URLs for .ashx (IHttpHander) handlers?

I have some REST services using plain old IHttpHandlers. I'd like to generate cleaner URLs, so that I don't have the .ashx in the path. Is there a way to use ASP.NET routing to create routes that map to ashx handlers? I've seen these types of…
Samuel Meacham
  • 10,215
  • 7
  • 44
  • 50
21
votes
1 answer

MVC: Route Get / Post to different controllers. How?

I am writing a MVC controller where I need to handle both, data return as well as a long poll "data has changed" like behavior from the SAME (!) url. NothingI can do about this - I am implementing a proxy for an already existing application, so I…
TomTom
  • 61,059
  • 10
  • 88
  • 148
18
votes
5 answers

ASP.NET routing on IIS 6

I have created a basic site using ASP.NET routing according to Mike Ormond's example "Using ASP.NET routing Independent of MVC". This works fine on my local machine running the built-in web server. However, when I deploy it to my server (Windows…
Peter
13
votes
2 answers

Run two web sites on same port on IIS 7.5?

We need to be able to run two versions of one ASP.net web application on the same intranet server and port number, but with one mapped to / and the other mapped to /experimental (not real names, but close enough). C:\inetpub\wwwroot\Version1 => …
user364825
  • 235
  • 1
  • 2
  • 11
12
votes
4 answers

ASP.Net Mvc 3 Url.Action method uses parameter values from previous request

When Urls are autogenerated using the Url.Action helper, if a page contains a line similar to @Url.Action("Edit","Student") is expected to generate a url like domain/student/edit and its working as expected. But if the requested url contains some…
Mat J
  • 5,422
  • 6
  • 40
  • 56
12
votes
3 answers

ASP.NET routing: Literal sub-segment between tokens, and route values with a character from the literal sub-segment

The reason I'm asking is because IIS protects certain ASP.NET folders, like Bin, App_Data, App_Code, etc. Even if the URL does not map to an actual file system folder IIS rejects a URL with a path segment equal to one of the mentioned names. This…
Max Toro
  • 28,282
  • 11
  • 76
  • 114
11
votes
2 answers

Regarding ASP.NET routing in WebForm & Asterisk sign

I saw people use asterisk sign at the time of routing in webform. i just do not understand the importance of Asterisk sign like below one routes.MapPageRoute( "View Category", // Route name "Categories/{*CategoryName}", // Route…
Keith Costa
  • 1,783
  • 11
  • 35
  • 68
11
votes
1 answer

ASP.NET MVC4... is "BIN" a reserved keyword?

I have a stock query application that returns data based upon a stock symbol. Basically, the AJAX call goes to ~/Stocks/GetStockData/{id} where the {id} is the stock symbol. This works fine... generally. Today I found that the stock "Progressive…
Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254
10
votes
2 answers

Stackoverflow style URL (customising outgoing URL)

If I navigate to the following stackoverflow URL http://stackoverflow.com/questions/15532493 it is automatically appended with the title of the question like so: http://stackoverflow.com/questions/15532493/mvc-custom-route-gives-404 That is, I can…
Benjamin Gale
  • 12,977
  • 6
  • 62
  • 100
9
votes
4 answers

ASMX web services routing in ASP.NET Web Forms

NOTE: There is no MVC in this code. Pure old Web Forms and .asmx Web Service. I have inherited a large scale ASP.NET Web Forms & Web Service (.asmx) application at my new company. Due to some need I am trying to do URL Routing for all Web Forms,…
milan m
  • 2,164
  • 3
  • 26
  • 40
9
votes
1 answer

ASP.NET routing with a NOT equal to constraint

I have a route like so: routes.MapRoute ( "Profile", "profile/{username}", new { controller = "Profile", action = "Index" }, new { username = @"^(getmoreactivity)" } ); This works fine for all users but I have a situation…
9
votes
1 answer

Why does ASP.NET Routing take precendence over web.config Http Handlers section?

Our shop is integrating ASP.NET MVC into a large web application that utilizes custom & 3rd party HTTP Handlers defined in web.config under system.webServer\handlers. Leveraging HTTP Handlers in this way has been great for us because we don't need…
1
2 3
26 27