Click here to Skip to main content
15,920,111 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: .Net Core 3.2 Controller, using route and HttpGet attribute with CreatedAtRoute Pin
jkirkerx20-Aug-20 4:33
professionaljkirkerx20-Aug-20 4:33 
I didn't think of it like that.

At the beginning before I wrote the JWT auth policies, I tried to make the app really code compact. It was just "GetOrder", then I renamed it to "GetAdminOrder" to reflect JWT Auth. I really need to streamline this naming.

return CreatedAtRoute directly? No need to return Ok. I wonder if using Ok wraps the JSON result in that extra envelope. I'll find out here, takes 10 mins to test it.

I made the code changes, and will give it a try, I'm sure it will work fine. I really don't want the extra route decorator anyways, it was just part of an example of using CreatedAtRoute I picked up over a year ago. I must admit that using CreatedAtRoute is pretty handy.
var result = CreatedAtRoute("GetAdminOrder", new { orderId = order.Id }, order);
return Ok(result);

[HttpGet("GetAdminOrder/{orderId}", Name = "GetOrder"), Authorize(AuthenticationSchemes = AuthSchemes, Policy = AuthPolicies.Admin)]        
If it ain't broke don't fix it
Discover my world at jkirkerx.com

GeneralRe: .Net Core 3.2 Controller, using route and HttpGet attribute with CreatedAtRoute Pin
jkirkerx21-Aug-20 9:43
professionaljkirkerx21-Aug-20 9:43 
Questionsubmit button Pin
Member 1491014318-Aug-20 23:40
Member 1491014318-Aug-20 23:40 
SuggestionRe: submit button Pin
Richard MacCutchan19-Aug-20 0:16
mveRichard MacCutchan19-Aug-20 0:16 
GeneralRe: submit button Pin
Member 1491014319-Aug-20 0:34
Member 1491014319-Aug-20 0:34 
GeneralRe: submit button Pin
Richard MacCutchan19-Aug-20 0:41
mveRichard MacCutchan19-Aug-20 0:41 
GeneralRe: submit button Pin
Member 1491014319-Aug-20 1:05
Member 1491014319-Aug-20 1:05 
AnswerRe: submit button Pin
F-ES Sitecore19-Aug-20 0:37
professionalF-ES Sitecore19-Aug-20 0:37 
GeneralRe: submit button Pin
Member 1491014319-Aug-20 0:46
Member 1491014319-Aug-20 0:46 
GeneralRe: submit button Pin
F-ES Sitecore19-Aug-20 1:46
professionalF-ES Sitecore19-Aug-20 1:46 
AnswerRe: submit button Pin
Otekpo Emmanuel19-Aug-20 7:56
Otekpo Emmanuel19-Aug-20 7:56 
QuestionRe: submit button Pin
ZurdoDev28-Aug-20 4:51
professionalZurdoDev28-Aug-20 4:51 
QuestionWhy ASP.NET MVC\Core ??? Pin
Steve Naidamast16-Aug-20 6:38
professionalSteve Naidamast16-Aug-20 6:38 
AnswerRe: Why ASP.NET MVC\Core ??? Pin
Mycroft Holmes16-Aug-20 12:53
professionalMycroft Holmes16-Aug-20 12:53 
GeneralRe: Why ASP.NET MVC\Core ??? Pin
Steve Naidamast18-Aug-20 6:51
professionalSteve Naidamast18-Aug-20 6:51 
GeneralRe: Why ASP.NET MVC\Core ??? Pin
Mycroft Holmes18-Aug-20 12:11
professionalMycroft Holmes18-Aug-20 12:11 
GeneralRe: Why ASP.NET MVC\Core ??? Pin
Steve Naidamast18-Aug-20 12:28
professionalSteve Naidamast18-Aug-20 12:28 
AnswerRe: Why ASP.NET MVC\Core ??? Pin
Richard Deeming16-Aug-20 22:47
mveRichard Deeming16-Aug-20 22:47 
AnswerRe: Why ASP.NET MVC\Core ??? Pin
F-ES Sitecore17-Aug-20 1:10
professionalF-ES Sitecore17-Aug-20 1:10 
AnswerRe: Why ASP.NET MVC\Core ??? Pin
Steve Naidamast18-Aug-20 4:22
professionalSteve Naidamast18-Aug-20 4:22 
GeneralRe: Why ASP.NET MVC\Core ??? Pin
F-ES Sitecore18-Aug-20 5:14
professionalF-ES Sitecore18-Aug-20 5:14 
GeneralRe: Why ASP.NET MVC\Core ??? Pin
Steve Naidamast18-Aug-20 5:40
professionalSteve Naidamast18-Aug-20 5:40 
GeneralRe: Why ASP.NET MVC\Core ??? Pin
F-ES Sitecore18-Aug-20 6:24
professionalF-ES Sitecore18-Aug-20 6:24 
GeneralRe: Why ASP.NET MVC\Core ??? Pin
Steve Naidamast18-Aug-20 7:30
professionalSteve Naidamast18-Aug-20 7:30 
GeneralRe: Why ASP.NET MVC\Core ??? Pin
F-ES Sitecore18-Aug-20 7:54
professionalF-ES Sitecore18-Aug-20 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.