URL.Action kann keine URL beheben, während andere Aktionen funktionieren

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: URL.Action kann keine URL beheben, während andere Aktionen funktionieren

by Anonymous » 23 Apr 2025, 09:36

Ich habe einen Web -API -Controller (Erben von ControllerBase) für Rechnungen. Es enthält diese Endpunktdefinitionen: < /p>

Code: Select all

[HttpGet]
[Route("{id:guid}")]
public async Task GetInvoiceByIdAsync(Guid id,
CancellationToken cancellationToken)

[HttpPut]
[Route("{id:guid}")]
public async Task UpdateInvoice(Guid id,
[FromBody] UpdateInvoiceRequest source,
CancellationToken cancellationToken)
< /code>
Die tatsächliche lokale URL für beide: < /p>
https://localhost:7009/api/Invoice/5B1B7CAB-CC89-48A9-8D9D-3F10E244D0CC
getInvoiceByIdaSync ist GET , UpdateInvoice wird erwarten. Lösen Sie die URLs.

Code: Select all

var getUrl = Url.Action(nameof(GetInvoiceByIdAsync), "Invoices", new { id = Guid.NewGuid() }) ?? string.Empty;
var putUrl = Url.Action(nameof(UpdateInvoice), "Invoices", new { id = Guid.NewGuid() }) ?? string.Empty;
Die Puturl löst die oben erwähnte URL korrekt auf.>

Top