I am trying to create a "Generate random movie" button in the home view, so that when I click in that button, it redirects me into a random movie.

So the URL should go from Home/Index to Movies/Details/"Random Id"

I also, dont know if thats the best way to do this.

I´ve tried an ActionLink

@Html.ActionLink("Generate New Movie", "Movies/Details")

However, there are 2 missing things in here.

First, the random id, that I dont know how to do it

And second, when I click the ActionLink it goes to Home/Movies/Details

One more thing, is there any way to do it with a button or something, because a hyperlink is a little bit ugly

Edit:

  <div class="row">
        <div class="col-md-4">
            <h2>Random Movie Generator</h2>
            <p>

            </p>
            @Html.ActionLink("Somethin", "Movies/Details")
        </div>

The ID i am talking about is the Movies.MoviesID from a database. For example in the Movie view when I click a movie details it redirects to its details. I use this:

@Html.ActionLink("Detalhes do Filme", "Details", new { id = item.MovieID })

Related posts

Recent Viewed