0

I want to access page when user clicks to button.

By changing url, such as ..../Member/Batch/Create I want my site redirect user to another page.

How can I do this via ASP.NET Core MVC 3.1?

1

2 Answers 2

1

Use:

<a href="@Url.Action("Batch", "Member", null)">Create Batch</a>

See this answer and help for more details.

Sign up to request clarification or add additional context in comments.

Comments

0

Do you mean we could only access the controller by using button?

If this is your requirement, you could try to check the Request.Headers["Referer"].ToString() to make sure just which url could access this controller.

Like below:

    public IActionResult Privacy()
    {
        var re = Request.Headers["Referer"].ToString();
        if (Request.Headers["Referer"].ToString() != "https://localhost:44342/home/index")
        {
            return View("Error");
        }
        else
        {
            return View();
        }

    }

Result:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.