简体   繁体   中英

How to pass list as a parameter in response.redirect

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.

ex:System.Collections.Generic.List1[IDataEntities.ISearchResultsEntity]

Prob2:I have a method call in ajax post,I am able to navigate to the method but inside i have done response.redirect which fails saying "Threadabort exception"

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]';

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM