1

I'm very new too ASP.net and after a ton of searching could not find an answer to my issue. Right now we have the current route configured in Global.asax.cs

config.Routes.MapHttpRoute(
    name: "default",
    routeTemplate: "version/{controller}",
    defaults: new { category = "all" }
);

which will give https:localhost:0000/project/version/index

but I want to be able to have all requests from https:localhost:0000/api/version/index to lead be mapped to that location.

I was wondering if this is a routing issue or something that needs to be done in Web.Config

Jason P
  • 26,984
  • 3
  • 31
  • 45
Jai.B
  • 21
  • 4
  • If you are new in MVC, I would suggest Attribute Routing, you can easily create route whatever you want https://blogs.msdn.microsoft.com/webdev/2013/10/17/attribute-routing-in-asp-net-mvc-5/ – Pankaj Rawat Oct 20 '16 at 15:52

1 Answers1

0

So this older endpoint is no longer in use? What you want is a 301 redirect (which forwards the URL while informing the caller that the location has changed:

There's more information on this question:

ASP.NET MVC 4 - 301 Redirects in RouteConfig.cs

Edit:

The "localhost:0000/projectname" portion is based on how it's bindings are set in IIS. If you're manually setting up a site in full IIS this is an obvious task. When debugging you're often using IIS Express and the bindings can be set automatically. You can find and edit them by cracking open the applicationhost.config file as explained here:

Where is the IIS Express configuration / metabase file found?

Community
  • 1
  • 1
Nick Kuznia
  • 1,698
  • 17
  • 27
  • I would like that the current endpoints get routed to if someone was to call a completely separate URL in the same local host. The problem now is that no matter what i do it will always place the project name after the local host ex (localhost:0000/project) where i would like it to accept requests that don't have the project name – Jai.B Oct 20 '16 at 15:57