0

I'm currently struggling in a problem where I need to register a route like:

https://localhost:44300/oneController/{Guid}/method1?param1=10000&param2=stuff

What I've tried was something similar to this:

[HttpGet]
public async Task<ActionResult> method1(Guid id, int param1, string param2)
{
    ...
}

However, this does not seems to work, any ideas to resolve this issue?

3
  • 2
    may be you need to switch {Guid} with method1 Commented Feb 6, 2020 at 16:29
  • Also, should change {Guid} to {id}. Commented Feb 6, 2020 at 16:31
  • @Sajid, actually op wants to call method1 with the given route and due to different structure of route instead of 1`controller\actionmethod?querystringparameters, he want id to be part of URL. changing {guid}` to method1 while not help here. correct me if I am wrong Commented Feb 7, 2020 at 2:09

1 Answer 1

3

You can use RouteAttribute, like

[Route("{id:guid}/method1"), HttpGet]
public async Task<ActionResult> method1(Guid id, int param1, string param2)
{
    ...
}

Good to read MSDN Documentation: Attribute Routing in ASP.NET

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.