How to pass list as a parameter in response.redirect

后端 未结 3 2017
予麋鹿
予麋鹿 2021-01-26 10:28

Prob1:I have 2 lists which i want to access in the next page which i will be redirecting. Current result, When i pass my result, in the url it shows the List data type.

<
相关标签:
3条回答
  • 2021-01-26 10:55

    Prob 1: You need to comma-separate your list values. Need more info to give you exact code as I have no idea if this is asp.net or asp.net mvc or something else. If, say, this is redirecting to another action in asp.net mvc your receiver action param needs to be a List and you redirect to /Receiver?param1=value1,value2,value3 ...

    Hopefully that answers your question

    Prob 2: Cant redirect from an ajax request. Need to return something special and handle it on the front-end.

    0 讨论(0)
  • 2021-01-26 10:59

    Prob1. Add a public property to current page with type List<Class>. On the next page (target page of redirect()), add prevoiusPageType tag in ASPX file. Now you can access Page.PreviousPage.ListToAccess.

    Prob2. Add false as param for redirect like Response.Redirect("<URL-of-target-page", false);

    0 讨论(0)
  • 2021-01-26 11:10

    use Session to hold your list as below

    Session["mylist"] = list;
    

    you can access it from next page, there are many other ways. please check this link.

    when you call Response.Redirect call it as below

    Response.Redirect(url, false);
    Context.ApplicationInstance.CompleteRequest();
    

    but don't do Redirect on ajax call from server side, ones ajax call completed you can redirect from client side call.

    on success ajax call back method

    window.location = '[url to redirect]';
    
    0 讨论(0)
提交回复
热议问题