Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. A question about routing attribute

A question about routing attribute

Scheduled Pinned Locked Moved ASP.NET
questionjson
3 Posts 3 Posters 23 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex Dunlop
    wrote on last edited by
    #1

    Hi, What does [Route("id:guid")] mean in the following code? (This code is a part of an API)

    [HttpGet]
    [Route("id:guid")]
    [ActionName("GetCard")]
    public async Task GetCard([FromRoute]Guid id)
    {
    var card = await context.Cards.FirstOrDefaultAsync(x => x.Id == id);
    if(card != null)
    {
    return Ok(card);
    }
    return NotFound("Card not found");
    }

    L 1 Reply Last reply
    0
    • A Alex Dunlop

      Hi, What does [Route("id:guid")] mean in the following code? (This code is a part of an API)

      [HttpGet]
      [Route("id:guid")]
      [ActionName("GetCard")]
      public async Task GetCard([FromRoute]Guid id)
      {
      var card = await context.Cards.FirstOrDefaultAsync(x => x.Id == id);
      if(card != null)
      {
      return Ok(card);
      }
      return NotFound("Card not found");
      }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Attribute Routing in ASP.NET Web API 2 | Microsoft Docs[^]

      L 1 Reply Last reply
      0
      • L Lost User

        Attribute Routing in ASP.NET Web API 2 | Microsoft Docs[^]

        L Offline
        L Offline
        Leeladhar Ladia
        wrote on last edited by
        #3

        This is the way to route you have to go through the website: Routing in ASP.NET Core | Microsoft Docs[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups