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

How do I initialize a webhook receiver in ASP.Net MVC

I'm following this guide here for installing and using webhooks in ASP.Net MVC, but it looks like this guide is for a wep api type project. I'm using a MVC type project and there is no Register method, unlike a API project. In MVC we have a…
chuckd
  • 13,460
  • 29
  • 152
  • 331
2
votes
2 answers

Routing with Areas and Controller Name (asp.net core)

To stop my application from getting cluttered I started working with areas. But now I always have to call: http://localhost:49358/Document/Document/ instead of: http://localhost:49358/Document/ How can I change my route to access the Controllers by…
Yush0
  • 1,547
  • 18
  • 22
2
votes
1 answer

LowercaseUrls = true in RouteOptions doesn't affect URLs with non-Roman characters

In ASP.NET MVC CORE 2.0 public void ConfigureServices(IServiceCollection services) { services.Configure(options => options.LowercaseUrls = true); services.AddMvc(); } New post Works fine giving…
Serg
  • 6,742
  • 4
  • 36
  • 54
2
votes
2 answers

Attribute routing returns 404

but I am new to attribute routing, and I have no idea why this isn't working while everything else does so I have this [RoutePrefix("api/statistics")] public class StatisticsController : ApiController And then I have [HttpGet] …
Harry
  • 3,333
  • 3
  • 18
  • 28
2
votes
1 answer

How to connect Multiple MVC.net Application with other MVC.net Applications?

Is it possible to have an ASP.NET MVC Server that communicates with other MVC.net Applications? ( example is shown in image link ) Example A client first communicates with the Main Server. The Main Server redirects his request to one of the other…
2
votes
2 answers

Call web api c# by passing oauth token along with parameter

I'm using custom oauth in web API for authentication. Now i want to call web api method from MVC controller. Web API method: public class UserController : ApiController { [Authorize(Roles = "Admin")] [HttpPost] [ActionName("UserById")] …
2
votes
0 answers

Omit middle part of URL

I am developing a blog web app and I want individual blog post links to look like this: http://example.com/Post/2017/1/22/post-title, but at the same time, if there are more than two posts in a day, the link for the second one should look like…
n0rd
  • 11,850
  • 5
  • 35
  • 56
2
votes
0 answers

asp.net core routing (attribute routing)

I was wondering what is the best way to go about routing? I have a Index method like: public IActionResult Index(int parentId = -1, int page = 0){ ... return(model); } so since this action has default values, I would like the user be able…
shaahin
  • 108
  • 1
  • 8
2
votes
0 answers

When trying to load views from my database, my routing is not getting called

Trying to follow this simple example here to load views from a database: http://www.binaryintellect.net/articles/e544d1d3-e47e-4ced-bd4d-8c1eaefbdc31.aspx The problem is once I register my VirtualPathProdvider my routing no longer gets called. This…
Slee
  • 27,498
  • 52
  • 145
  • 243
2
votes
1 answer

RouteLink with dynamic parameters

I'm trying to store routes in database, and list those based on parameters. Kinda like: Route = "NewsDetail" ParamKey 1 = "NewsID" ParamVal 1 = "4" .... 2..3 And I would like to know how I create those routeparameters for the link... <%=…
Lasse Edsvik
  • 9,070
  • 16
  • 73
  • 109
2
votes
1 answer

Configure ASP.NET Core Router run match multiple middlewares

I am trying to use Microsoft.AspNetCore.Routing with multiple widdlewares which can match. For example: builder.MapRoute("api", async c => {}) // Match all api calls builder.MapRoute("api/user", async c => {}) // Only…
2
votes
1 answer

How can Routing for WebForms show a Google Adwords query string?

I've been on this almost 2 days and I'm really feeling stuck. I've been running a site for a few years using MapPageRoute to create urls for several hundred "pages" that are all handled by "~/default.aspx" via database lookups for page data. The…
secretwep
  • 706
  • 1
  • 12
  • 28
2
votes
1 answer

MVC routes with static Prefix

I have two routes in my routeConfig files as follow. Route with admin prefix which handles request for admin part default Route without a prefix, for which I have added a datatoken to map routes in candidate Area routes.MapRoute( …
2
votes
1 answer

Web API: Odata route always returning a 404 response

I am new to OData. I have built an ASP.NET Web API controller as shown below: using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Web.OData.Routing; namespace HelloWebApi.Controllers { public class TestsController :…
Jacob Thomas
  • 41
  • 2
  • 6
2
votes
2 answers

How to adjust asp.net URL routing based on domain/host?

What's the best way to adjust the path destination for a routing table created in the global.asax Application_Start event based on the domain/sub domain/host? The following worked in IIS6, but with IIS7 the request object is decoupled from the…
DrewF
  • 91
  • 9