none
dot net core route - how to hide controller while calling api RRS feed

  • Question

  • Hi Team,

    Framework - Dot Net Core 2.0 

    Application - Rest Web API 

    I want to remove the controller name from my URL (for one specific controller). For example:

    http://mydomain.com/MyController/MyAction

    I would want this URL to be changed to:

    http://mydomain.com/MyAction

    Startup.cs file

               

     public void ConfigureServices(IServiceCollection services)
            {
                       services.AddMvc();          
            } public void Configure(IApplicationBuilder app, IHostingEnvironment env)
            {
                          app.UseMvc();

            } 

    Controller file.

     [Route("[controller]/[action]")]

    public class ValueController : Controller
        {

           [Route("{username}")]

            [HttpGet]
            public GetUserRoles(string username)
            {
              
            }

         }

    Regards,

    Pritesh

    • Moved by CoolDadTx Friday, September 28, 2018 2:47 PM ASP.NET related
    Thursday, September 27, 2018 11:09 PM

All replies