2
I have tried several ways, I need to take the value of the current URL, and move to the next page, so that after the action of the create is completed, I go back to the URL that was passed, how can I proceed? Thank you.
I’m trying this way:
string urlAnterior = Request.Headers["Referer"].ToString();
if (urlAnterior.Contains("Pagina"))
return RedirectToAction("");
else
return RedirectToAction("");
And also so:
string urlAnterior = Request.Headers["Referer"].ToString();
if (urlAnterior.Contains("Pessoa"))
return RedirectToAction("Edit", "Pessoa");
else
return RedirectToAction("Index", "ContaReceber");
But neither worked, wanted to save the URL in a variable for example, and move to the next page, so he would know correctly, where to return.
EDIT:
This is where I call the create page of accounts receivable, passing the id parameter of the person in Edit.
<a asp-page="/ContaReceber/Create" asp-route-id="@Request.Query["id"]" class="btn btn-primary btn-sm">Criar nova Conta</a>
Like you’re trying to do?
– Marco Souza
I edited the question.
– Mariana
Unable to use the HTTP REFERER header?
– Woss
I’m new to the language, what do you mean HTTP REFERER header? If you can help me.
– Mariana
You want to go back to a previous page of the same controller ?
– Marco Souza
I have the CREATE page of Accounts Receivable, this page can be called inside the Edit of people, or else from the INDEX of Accounts Receivable, I want it to return, from where it was called.
– Mariana
O Cabecalho
http_referer
(yes, it’s spelled "referer" and not "referrer" because the blessed one who created it misspelled the name) it serves to get the previous (or source) url of a request. When you open the page directly (or do a redirect show), you obviously won’t have anything relevant in HTTP_REFER– Wallace Maxters
By way of curiosity: Referer or Referrer?
– Wallace Maxters
the gambiara title you can also receive your URL as parameter of your CREATE (get) action and store in a Tempdata and CREATE POST only recover the Tempdata variable ...
– Marco Souza
@Wallacemaxters so in my case I can’t use http referer? That’s it ?
– Mariana
@Marconciliosouza, in the case of create, if it is called in people I already pass a parameter, I would pass along ? Is that it? I’ll put in the question, what do I call in people.
– Mariana
Young, @marianac_costa, ever thought about going to
url
what do you want as a parameter in GET? (I did it yesterday in an implementation here)– Wallace Maxters
@Wallacemaxters I edited the question with the part I already pass a parameter, how would I pass the url ? Sorry, I’m still learning this language.
– Mariana
@marianac_costa watch out for what is using the tool to not use wrong. The snippet code (
</>
) are for full HTML/JS/CSS examples. To whichever something else, use the button{}
, or just indent the code with 4 spaces in the question. Even if it’s only HTML, CSS or JS that there’s nothing to execute, do not use the snippet. Tip: any other language like this, use{}
.– Woss
@marianac_costa, have you tried Urlreferrer ? It is a property that returns just the previous url. Note my answer below.
– Pedro