I'm trying to route to areas based on a subdomain while having the URL not include the Area parameter.

I'd like to be able to go the following routes for example

example1.domain.com/login

example1.domain.com/landingpage

example2.domain.com/login

example2.domain.com/landingpage

I'd like to have each subdomain route to a different Area. I've tried following this post Is it possible to make an ASP.NET MVC route based on a subdomain? which led me to http://benjii.me/2015/02/subdomain-routing-in-asp-net-mvc/. But I can't seem to figure out how to not have the Area parameter in the URL.

How can I get the correct URL schema I'm looking for? {subdomain}.domain.com/{action}/{id}

This question already has an answer here:

Hello StackOverflow members,

I have two controllers:

public class FirstController : Controller
{
    public string Index()
    {
        return "FirstController - Index";
    }
}

public class SecondController : Controller
{
    public string Index()
    {
        return "SecondController - " + language;
    }
}

And I have two URLs: 1. mysite.com/ 2. en.mysite.com/

I expect to get:

  1. FirstController - Index

  2. SecondController - en

where en can be any param.

How should I adjust my Global.asax to fix this issue:

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

This question already has an answer here:

Hello StackOverflow members,

I have two controllers:

public class FirstController : Controller
{
    public string Index()
    {
        return "FirstController - Index";
    }
}

public class SecondController : Controller
{
    public string Index()
    {
        return "SecondController - " + language;
    }
}

And I have two URLs: 1. mysite.com/ 2. en.mysite.com/

I expect to get:

  1. FirstController - Index

  2. SecondController - en

where en can be any param.

How should I adjust my Global.asax to fix this issue:

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    }
}

I'm an experienced .NET developer, making my first steps in .NET Core in the passed few days, more specific in building RESTful APIs using ASP.net Core.

I know there are 2 possible routing options - Convention Routing (traditional) vs the Attribute Based Routing (newer).

I've read that the ASP.net core's development team recommendation is to use Attribute Based Routing for APIs rather than the tradition Convention Based routing, which is more suitable for MVC applications.

I'd really like to understand - Why?

It seems that the attribute based routing makes us write more code ending up having the same behavior as the conventional routing.

I am working on angular application, i am using asp.net mvc(not .html page). in which i need dynamic menu + routing + i want to remove # from url. how to use .cshtml page as templates?is it possible?

i am using angular 1.5.0

i already tried below mentioned solutions but its not working for me. http://csharp-video-tutorials.blogspot.in/2016/02/remove-from-url-angularjs.html (this solution working fine for html templates but not for cshtml)

Is angular routing template url support for .cshtml file in ASP.Net MVC 5 Project?

please let me know if any one has solution for this problem.

Many Thanks.

Good.

I am making an application in ASP.NET MVC and publishing it does not work correctly because the paths are not correct.

Let's say it's published in

https://test.depruebas.es/jgs/p12/Chat The first login screen that is the one that starts the project shows it well, but when I give the button of the BeginForm of the form, I should send to the Home controller and action Index

  

 @using (Html.BeginForm ("Index", "Home", FormMethod.Post))

Pressing the button sets this route to me:

test.depruebas.es/Chat/Home/Index

but really should put

test.depruebas.es/jgs/p12/Chat/Home/Index

How can I specify that I get the subdomain of the route?

I am a beginner to Emgu CV and to C#/ASP.NET. I just bumped into it when I was exploring possible routes to transform my standalone C++ application to a web application. I have tried the C# based samples and they work great.

However, most of the controls (ImageBox() for instance) are based on System.Windows.Forms. How can I transform them to System.Web. controls, so that I can create a ASP.NET web form?

I understand that MVC and Web API (and off late it has even been included in the ASP.NET runtime to) have a routing engine that takes the URI and routes it to the right controller (or HttpHandler in the case of Web Forms).

But my question is -- the routing engine of MVC lives in a separate library, the MVC library. So even before the MVC routing engine comes to work, there must be something within the ASP.NET runtime that decides that the request is for MVC, so let's load the MVC library and then give the request to MVC's routing engine.

What component is that?

similar to https://stackoverflow.com/questions/5863984/asp-net-mvc-many-routes-always-only-one-controller#=

i have a .net 4.7 MVC project project

my config route are as follows (following from the above post)

      config.Routes.MapHttpRoute(
    name: "AllRoutes",
    routeTemplate: "{*url}",
    defaults: new
    {
      controller = "base",
    });

my base controller in my .net 4.7 project

public class BaseController : ApiController
{
  [HttpGet]
  public IHttpActionResult Get(HttpRequestMessage request)
  {
    return Ok();
  }

  [HttpPost]
  public IHttpActionResult Post(HttpRequestMessage request)
  {
    return Ok();
  }

  [HttpPut]
  public IHttpActionResult Put(HttpRequestMessage request)
  {
    return Ok();
  }

  [HttpDelete]
  public IHttpActionResult Delete(HttpRequestMessage request)
  {
    return Ok();
  }
}

now i'm porting my project into a .net Core 2.0

i can't seem to setup the same thing

my config in the .net core project are as follows

      app.UseMvc(routes =>
  {
    routes.MapRoute(
      name: "AllRoutes",
      template: "{*url}",
      defaults: new
      {
        controller = "Base"
      }
    );

my base controller for my .net core project

//[Route("api/[controller]")]
public class BaseController : Controller
{
  [HttpGet]
  public IActionResult Get()
  {
    return Ok("get success");
  }

  // POST api/values
  [HttpPost]
  public IActionResult Post([FromBody]string value)
  {
    return Ok("post success");
  }

  [HttpPut]
  public IActionResult Put([FromBody]string value)
  {
    return Ok("put success");
  }

  [HttpDelete]
  public IActionResult Delete()
  {
    return Ok("delete success");
  }
}

any ideas?

I am trying to implement some convention-based routing in my new .NET 5 API, based on how Rails does it. I'm putting all of my controllers in a different namespace for each version, for example Controllers/v1/MyController. The way this is done in the new .NET is different to how it was done in previous versions.

I'm looking for something as described in this article, but even after looking through the asp.net docs and reading this article on routing, I am no closer to a solution.

My controllers currently look like this:

namespace SaleboatApi.Controllers.v1
{
    [Route("api/v1/[controller]")]
    public class MyController : Controller {
    ...

but I feel like if this is done right, I won't need the Route annotation.

Asp.net MVC enables you to work with "automatic routes" through the following default configuration:

routes.MapRoute(
   name: "Default",
   url: "{controller}/{action}/{id}",
   defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });

That way, when I type "site/controller/method" automatically the route is created according to naming conventions.

I'm starting now with Laravel, but from what I've seen, every route must be set manually. Is there any way to work with Laravel in the same way that works in Asp.net MVC on this issue of routes?