Skip to content

CreatedAtRoute with DateTimeOffset gives incorrect URL #11134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MikaelUmaN opened this issue Jun 12, 2019 · 3 comments
Closed

CreatedAtRoute with DateTimeOffset gives incorrect URL #11134

MikaelUmaN opened this issue Jun 12, 2019 · 3 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates ✔️ Resolution: Duplicate Resolved as a duplicate of another issue investigate
Milestone

Comments

@MikaelUmaN
Copy link

Describe the bug

DateTimeOffset string is formatted incorrectly in location link after returning CreatedAtRoute result.

To Reproduce

Steps to reproduce the behavior:

  • Given HttpPost route
  • Given a CreatedAtRoute result including a DateTimeOffset parameter
  • Then the location parameter should include a valid string representation of the DateTimeOffset value.
  • Instead, an erroneous value is given:
 content-length: 0 
 date: Wed, 12 Jun 2019 07:58:27 GMT 
 location: http://localhost:8081/api/monitor/IntradayOutlierMonitor/IntradayOutlierMonitor/06%2F13%2F2019%2007%3A26%3A21%20%2B00%3A00 
 server: Kestrel 

Expected behavior

String formatted in a manner that makes it parseable by AspNetCore if the target route is called.

Can be achieved manually by doing this:

return CreatedAtRoute(nameof(GetConfig), new { name = config.MonitorName, validFrom = config.ValidFrom.ToString() }, null);

that is, calling ToString() explicitly. Then the location parameter becomes:

http://localhost:8081/api/monitor/IntradayOutlierMonitor/IntradayOutlierMonitor/2019-06-13%2007%3A27%3A21%20%2B00%3A00
which is accetable to AspNetCore

Screenshots

I get errors uploading screenshots, but trying to use the uri results in the following json

{
errors: {
validFrom: [
"The value '06%2F13%2F2019 07:26:21 +00:00' is not valid."
]
},
title: "One or more validation errors occurred.",
status: 400,
traceId: "0HLNF1F0EM637:00000002"
}

@analogrelay analogrelay added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jun 12, 2019
@mkArtakMSFT
Copy link
Contributor

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimalistic repro project that illustrates the problem.

@mkArtakMSFT mkArtakMSFT added investigate Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Jun 12, 2019
@MikaelUmaN
Copy link
Author

Please see repo:
https://github.com/MikaelUmaN/AspNetCore-11134

Reproduce

CLI (sdk >= 2.2)

dotnet build
dotnet run

HTTP Client (e.g. cURL)

  1. POST http://localhost:5000/api/values

Response:
location:
http://localhost:5000/api/Values/06%2F13%2F2019%2008%3A43%3A24%20%2B00%3A00

  1. Put in browser

-> Error

@mkArtakMSFT mkArtakMSFT removed the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Jun 14, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.0.0-preview8 milestone Jun 14, 2019
@mkArtakMSFT mkArtakMSFT modified the milestones: 3.0.0-preview8, 3.1.0 Jun 25, 2019
@pranavkm
Copy link
Contributor

Thanks for the repro app @MikaelUmaN.

Unfortunately you're running in to a fairly problematic issue on the incoming end that we decided not to fix in the past: aspnet/Mvc#4599, aspnet/Mvc#6388. We do have an issue to do a fairly targeted fix during input: #11544. We'll use the other issue to track fixing this scenario.

@pranavkm pranavkm added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Aug 26, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates ✔️ Resolution: Duplicate Resolved as a duplicate of another issue investigate
Projects
None yet
Development

No branches or pull requests

4 participants