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

Cannot hit AspNetCore 3.1 MVC API endpoints when published

AspNetCore 3.1 MVC API. Conventional startup public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); …
1
vote
1 answer

.Net core MVC Controller with optional parameter routing rules breaking with null values

Wirking on a .net core app and the Startup settings are like below app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); …
Sebastian
  • 4,625
  • 17
  • 76
  • 145
1
vote
1 answer

How to append current DateTime as a string to a URL in RouteConfig.cs

So I have the following route in my RouteConfig.cs routes.MapRoute( name: "Student", url: "student", defaults: new { controller = "Home", action = "Student", id = UrlParameter.Optional } ); Based on this route, I have the following…
Rahul Sharma
  • 7,768
  • 2
  • 28
  • 54
1
vote
2 answers

How to register minimum routes for similar actions?

I have some actions: public partial class MyController : Controller { public ActionResult Action1() { } public ActionResult Action2(int id) { } public ActionResult Action3(string…
theateist
  • 13,879
  • 17
  • 69
  • 109
1
vote
2 answers

Html.Routelink output - ASP.NET C# MVC

I have a call that looks like this: <%= Html.RouteLink(item.displayName, "DisplayCategory", new { category = Html.Encode(item.displayName), subcat = item.searchName }) %> and I'm getting html that looks like…
Eric
1
vote
1 answer

mvc3 Routes setup as id, id2 id3

I have the following area routes setup. context.MapRoute( "Admin_default3", "Admin/{controller}/{action}/{id}/{id2}/{id3}", new { action = "Index" } ); context.MapRoute( "Admin_default2", …
Valamas
  • 24,169
  • 25
  • 107
  • 177
1
vote
2 answers

Asp.net mvc 3.0 tree structure page custom routing

I want to map all CMS pages url to single controller(PageController) and action(Details). How can I create custom routing to map all these urls?…
Zayar
  • 347
  • 2
  • 11
1
vote
1 answer

Disabling querystrings and using only paths with /

I'm using a form and subsequently an action to redirect to another page. Problem is the action redirect function always redirects with a query string and not a full path. The end url is: localhost/Get?Description="ddd"&Id=555 Whereas I'd like it to…
1
vote
1 answer

mvc lowercase route (error im getting is "RouteCollection is a nested class"

so i know there's this 2 main links talking about lowering the cases for the urls, here they are respectively: How can I have lowercase routes in ASP.NET MVC? http://goneale.com/2008/12/19/lowercase-route-urls-in-aspnet-mvc/ anyway, they're…
gdubs
  • 2,724
  • 9
  • 55
  • 102
1
vote
1 answer

c# mvc 2 - map a catchall route for all images

I am trying to make a route to catch all image requests via regex, and use a image http handler. I've tried adding regex's (as with routes.IgnoreRoute), however, I receive errors about the url parameter for routing. I have also tried the following…
frank
  • 11
  • 1
1
vote
1 answer

Mvc 3 redirecting routes behaving weirdly

I have been trying to solve this problem for a couple of days now with no success. The case is i have rewritten an old web forms site to mvc 3 and have a bunch of legacy url:s that need to be redirected to new url:s This is what the 2 routes look…
Kimpo
  • 5,835
  • 4
  • 26
  • 30
1
vote
1 answer

ASP.NET MVC routing across server

I need to route WCF data services request from one server to another server. Is it possible to route a request across servers using ASP.NET MVC routing module? What are the options available for routing WCF data services request across servers?
Vijay
  • 513
  • 1
  • 6
  • 16
1
vote
0 answers

How to change area name in url according to user role in MVC 5

I have a MVC app there is a single area folder name with Admin. I want to use same folder for all my user role like SubAdmin, SupAdmin and Admin. when user login with role super-admin need to show Supadmin in url Like:…
Prithvi Raj Nandiwal
  • 3,122
  • 3
  • 22
  • 34
1
vote
1 answer

How we can pass data from one view to another in ASP.NET mvc framework

I have a page(view) and on submit i transfer control to another page(view) and i want some values which was filled in first view to transfer to next. How we can achieve that in ASP.NET MVC?
user813598
  • 15
  • 3
1
vote
3 answers

ASP.net MVC Change in URL of the application

the current application on MVC can be accessed through URL Like: www.someserver.com/myapplication Now there is a request to change it to a new URL: www.someserver.com/NEWFOLDER/myapplication so my question is how will the MVC behave, will I have to…
JackMith
  • 45
  • 5