1

I am trying to pass page number value to controller so that with that page no value i can fetch the list, but the parameter is always null. Here is the code of

View Page

  @if (Model.First().page == 1)
            {


                <ul class="pagination disabled"><li class="disabled"><a href="#"> Previous </a></li></ul>
                <ul class="pagination" style="float:right;"><li>  <a href="/MovieGenre/Genre/@(Model.First().GenreID)?type=@(Model.First().GenreType)?PageNo=@(Model.First().page + 1)"> Next </a></li></ul>
            }
            else
            {

                <ul class="pagination"><li><a href="#"> Previous </a></li></ul>
                <ul class="pagination" style="float:right;"><li>  <a href="/MovieGenre/Genre/@(Model.First().GenreID)?type=@(Model.First().GenreType)?PageNo=@(Model.First().page + 1)"> Next </a></li></ul>
            }

Here is the Controller

public ActionResult Genre(int id, string type, int? PageNo)
        {
            if (PageNo == null)
            {
                PageNo = 1;
            }
            var client = new RestClient("https://api.APIProvide.com/3/genre/" + id + "/movies?page=" + PageNo + "&api_key=xxxxxxxxxxxxxxxxxxxxxxxx&language=en-US&include_adult=true&sort_by=created_at.asc");
            var request = new RestRequest(Method.GET);
            request.AddParameter("undefined", "{}", ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            string Movies = response.Content;

            JavaScriptSerializer serialize = new JavaScriptSerializer();
            MovieByGenre_GetList_Class objMovieByGenre_GetList_Class = serialize.Deserialize<MovieByGenre_GetList_Class>(Movies);

            List<MovieByGenre_GetList_Class> lstMovieByGenre_GetList_Class = new List<MovieByGenre_GetList_Class>();
            lstMovieByGenre_GetList_Class.Add(objMovieByGenre_GetList_Class);

            List<GenreList_GetList> lstMovies_Genre_List = GetGenreList();
            if (lstMovies_Genre_List.Any())
            {
                objMovieByGenre_GetList_Class.GenreList = lstMovies_Genre_List;
                lstMovieByGenre_GetList_Class.Add(objMovieByGenre_GetList_Class);
            }

            objMovieByGenre_GetList_Class.GenreID = id;
            objMovieByGenre_GetList_Class.GenreType = type;
            return View(lstMovieByGenre_GetList_Class);
        }

Thanks in advance

1
  • Check getters setters for model. Commented Nov 4, 2016 at 18:16

1 Answer 1

3

In the view, the link formed is to be changed.

<a href="/MovieGenre/Genre/@(Model.First().GenreID)?type=@(Model.First().GenreType)?PageNo=@(Model.First().page + 1)"> Next </a>

is to be changed to

<a href="/MovieGenre/Genre/@(Model.First().GenreID)?type=@(Model.First().GenreType)&PageNo=@(Model.First().page + 1)"> Next </a>

Tip: The valid query string has to start with "?" and the subsequent parameters need to be specified using "&".

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

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.