I am trying to use the following code to generate url string:
var x = @Url.Action("AddOrEditSaleOffer", "BuildingOffers", null);
However, the returned value somehow generates the the following url:
/BuildingOffers/AddOrEditSaleOffer/7
where 7 is a number that changes based on the id of the last edited Offer.
The code is in a partial view and is called using ajax call and after making an edit to the Building Offer record. I am expecting to get NO id but the url is appending an id somehow.
UPDATE:
I found the following question helpful to understand why I was facing this problem and also suggested work arounds: Prevent ambient route values from the URL from being added to Html.Action and Html.ActionLinks automatically in ASP.NET
Also, the following section in Microsoft Docs. discusses this issue: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-5.0#url-generation-reference
nullparameter?Url.Actionis considered more robust. The route pattern might change and a literal string would then break, whileUrl.Actiongenerates the correct url.