Questions tagged [asp.net-mvc-routing]

Questions about routing within ASP.NET (including MVC).

The ASP.NET Routing module is responsible for mapping incoming browser requests to particular ASP.NET handlers. It is commonly used to map ASP.NET MVC controller actions, but routing is also used with ASP.NET Web Forms, ASP.NET Web API, route attribute (Web API2) and custom handlers.

Learn more about ASP.NET Routing on MSDN

4131 questions
1
vote
2 answers

MVC Routing: Trying to get dynamic root value working

I am trying to define dynamic sections of my site with the root url of the site. I am having some trouble defining the right MVC Route for it. Can someone please help. My desired url will look like this: http://website.com/[dynamic-string] But I…
SpoiledTechie.com
  • 10,515
  • 23
  • 77
  • 100
1
vote
2 answers

Asp.net core web application with react template: in development, server checks mvc routes first, but in prodcution the server only returns index.html

I am trying to migrate an existing MVC application that uses razor pages into web API + ReactJS client. I'm doing this step by step which means I have migrated the homepage (Home/Index) plus a few other pages/features to react. There are links…
1
vote
1 answer

Attribute Routing With Parameters - Anchor Tag Helper Appending Route-Id Value

I have setup the "basic" routes in Startup.cs with nothing out of the ordinary (one for the standard routing and another for areas). They are below: app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "Areas", …
clockwiseq
  • 4,189
  • 9
  • 38
  • 61
1
vote
1 answer

routing to a webform using MVC routing

I have a MVC 2 project runnin in .net 3.5. There are some Webforms which i have in a separate folder called "Forms". I need to routing to be implemented for this page. Like, localhost/home.aspx should be re-directed to localhost/Forms/home.aspx.…
Raghav
  • 2,890
  • 7
  • 36
  • 56
1
vote
1 answer

How can i route this url to right routing map?

localhost/myfile.xml This url is requested and i am trying to convert it to Home controller's Config action . My solution is at below but exception says routing can't include '/' character . How i can do this ? routes.MapRoute("config", …
Freshblood
  • 6,285
  • 10
  • 59
  • 96
1
vote
1 answer

Tracing route handling in mvc? (Alternatives to Glimpse?)

Using VS2008/ASP.Net 3.5 i can't use Glimpse, but it would be very helpful if I could trace the route handling done by MVC some way. Route debugger/RouteMagic seems to be ASP.Net 4 too. I'm satisfied if I can get route/controller/view info to show…
Carl R
  • 8,104
  • 5
  • 48
  • 80
1
vote
2 answers

How to set common part of route (Prefix) from config.json for all Actions in Controller?

I have a controller with Route attribute as well as every Action with it`s own Route like: [Route("api/version/v1")] public class MyController : ControllerBase { [Route("receipts/verifyReceipt")] public IActionResult VerifyReceipt(...){....} …
1
vote
0 answers

ReloadRoutes with ServiceRoute throws "A route with the resolved virtual path has already been added" exception

We have build a RouteProvider that stores route data in a database. Occasionally (mostly during development), we want to reload the route table without having to restart the application. For that we call the ReloadRoutes method on the provider and…
VdesmedT
  • 9,037
  • 3
  • 34
  • 50
1
vote
1 answer

How to insert Route to the top of RouteCollection

I am need to insert a route during the mvc application processing. I am in stuck because i can use MapPageRoute only to add new route to the end of routings table, and i can use Insert to add route to the start of collection, but in this case i…
1
vote
0 answers

Web API not working with existing MVC application

If I create standalone webAPI project It is working fine. I am trying to configure webAPI in existing MVC project. I have done following steps. Create WebApiConfig class and done necessary configuration Registered the configuration in…
1
vote
4 answers

Asp.Net Core Scaffolded 'Register' and 'Login' redirect not working in Azure AppService

Asp.Net Core 3.0 app. I am using Entity Framework Identity individual authentication and have scaffolded in a Login page and a Register page. I have an SQL database in Azure. When I run on localhost, the registration & login work fine. I have…
1
vote
3 answers

How to manually set the Culture during a ASP.NET Core MVC request?

I'm looking for something similar like the old behaviour of setting the Culture and everything in the request after that has that Culture. Similar like ASP.NET 4.5: Thread.CurrentThread.CurrentCulture = culture_info;…
Dirk Boer
  • 8,522
  • 13
  • 63
  • 111
1
vote
2 answers

Is it possible to get the controller and the action (NOT THEIR NAME!!) based on the url?

I have found a dozens of threads about getting the name of the controller and method based on the url, I managed that just as well. Can I get the MethodInfo of the method based on their name automatically from the MVC engine, or do I have to do…
TDaver
  • 7,164
  • 5
  • 47
  • 94
1
vote
1 answer

Removing /Home in route for Home Controler

For Asp.Net Core 3.1 projects, how do I remove the requirement to have /Home in the url for actions in the Home controller? I tried decorating the controller with the attribute [Route("/")] but it does not work. The start up configuration is the…
Old Geezer
  • 14,854
  • 31
  • 111
  • 198
1
vote
2 answers

ASP.NET MVC IgnoreRoute method doesn't work correctly when URL starts with "/Views/"

I use ASP.NET MVC in my application. Users can specify their own images, styles, scripts by including them on the page. But when they specify URL to the file which not exists then routing mechanism tries to find controller and action by URL to image…
Anton Palyok
  • 1,249
  • 1
  • 16
  • 27
1 2 3
99
100