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

NullReferenceException on RouteTable.Routes

My ASP.NET MVC 3 web project was working fine, then I recompiled it and now I'm getting this error (some paths and namespaces changed to protect the innocent): Object reference not set to an instance of an object. Description: An unhandled…
David Gardiner
  • 16,892
  • 20
  • 80
  • 117
0
votes
1 answer

Asp .net core razor pages urldata

In the asp .net razor pages, there is the built in urldata. I use it to easily read from the url. https://learn.microsoft.com/en-us/aspnet/web-pages/overview/routing/creating-readable-urls-in-aspnet-web-pages-sites What is the equivalent in asp…
Wallace B. McClure
  • 1,165
  • 1
  • 15
  • 31
0
votes
1 answer

How to set the System.Web.WebPages.WebPage.Model property

I am planning on creating a custom route using ASP.NET Web Pages by dynamically creating WebPage instances as follows: IHttpHandler handler = System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath("~/Default.cshtml"); How can I supply an…
Alfero Chingono
  • 2,663
  • 3
  • 33
  • 54
0
votes
1 answer

Routing Issues in .NET core After Upgrade

I have upgraded the solution from 2.2 to 3.1. Everything was running smoothly in 2.2 . After the upgrade, i have got routing issues. It is unable to route to a controller of a different project in the solution. With 2.2, i was using …
0
votes
1 answer

Routing swap In ASP.NET MVC

I have A controller like that public class OldController : Controller { public ActionResult Index(int ID, int Year) { return View(); } } And it use a route Like /Old/Index?ID=1000376&Year=566641393 I create a modified…
hema vic
  • 49
  • 4
0
votes
1 answer

ASP.NET and Custom Routing to the default page

I have made the routing in asp.net to work correctly .But still if i type the Address with Default.aspx it's surpassing my routes and hitting the Page. 2)As well as For the First request of my application is not hitting the route handler .ie…
satish
  • 2,425
  • 3
  • 23
  • 40
0
votes
1 answer

.NET URI Routing MapPageRoute issue

Any ideas on how to resolve this issue? My Global.aspx: protected void Application_Start(object sender, EventArgs e) { RouteTable.Routes.MapPageRoute("users"); } The non-generic method …
0
votes
0 answers

How to create localized url in .net core?

I have implemented localization in my .net core app and I am using cookies to change the culture. Now I want that my current culture should also in url How can i achieve this. To change Url what i am doing is:- public void…
0
votes
1 answer

FormatAttribute needs forward slash for action without parameter

I have a GET method without parameter and want below to work /api/books.xml This however works with forward slash /api/books/.xml [Route("api/[controller]")] [ApiController] public class BooksController : ControllerBase { [HttpGet] …
Arvind Singh
  • 733
  • 1
  • 10
  • 31
0
votes
1 answer

iis 7 /asp.net doesn't obey error pages settings on .net4 web site

I've just noticed in my logs that if there is a "." at the end of the url that doesn't exist on a .net 4 integrated apppool, iis 7.5 does not display your preset 404 url but default not found page. I have my custom 404 url on both iis and asp.net…
nLL
  • 5,662
  • 11
  • 52
  • 87
0
votes
1 answer

Best practice for making links that take advantage of clean urls

I'm using ASP.NET 4 and the routing engine. In my Global.asax I have something like this. routes.MapPageRoute( "Items", "manager/items", "~/Manager/Item/Items.aspx" ); Is writing a link this this…
The Muffin Man
  • 19,585
  • 30
  • 119
  • 191
0
votes
2 answers

ASP.NET MVC Routing? // UrlParamter.Optional Vs Empty String

What is the actual difference between these two routes ? & These two routes are the same? //Route 1. routes.MapRoute("SampleRounteOne" , "{controller}/{action}/{id}" , new {id = UrlParamter.Optional}) //Route 2. routes.MapRoute("SampleRounteTwo" ,…
Rehan Shah
  • 1,505
  • 12
  • 28
0
votes
1 answer

ASP.NET WebForms GetVirtualPath always returns null

I am just getting introduced to ASP.NET routing and have two routes registered at the moment: routes.MapPageRoute( "default", "{Path}/{Name}.aspx{Query}", "~/Default.aspx", true, …
Alfero Chingono
  • 2,663
  • 3
  • 33
  • 54
0
votes
1 answer

Asp.net Core 2.1 Routing Issue

I tried some routing in asp.net core 2.1 and facing a issue with routing... Startup.cs -> Configure Method app.UseMvc(routes => { routes.MapRoute( name: "default", template:…
C J
  • 429
  • 1
  • 10
  • 34
0
votes
1 answer

Hosting MVC 4 Application in IIS Application

I have several applications deployed to IIS. I created a site for each application and mapped them using different port number. Recently, I was asked to use virtual directory instead of mapping them using different port number. I created the…
Jean B
  • 343
  • 1
  • 6
  • 19