Hai

I am creating one web application

i am using xml String with one containing xml Output to assign that temporary variable..

this my requirement

I want to transfer one xml file to another or Redirected web page

how to transfer xml file or large data to another page

i am using ViewState and Query String

i am using ViewState

but another page the viewstate value is nothing

please help how to transfer..

reply me..

Dani AI

Generated

For : ViewState is page‑scoped and will not survive a redirect, and QueryString is limited and visible. As suggested, storing the XML on the server is the usual approach. Below are practical, safe options with quick examples and tradeoffs so you can pick the right one for your scenario.

If the target page can be executed in the same request, use Server.Transfer and HttpContext.Items (no serialization, no extra server memory per user beyond the request). The browser URL does not change, though.

Context.Items["xml"] = xmlString;
Server.Transfer("Target.aspx");

If you must redirect (new request), choose between Session, a short‑lived server cache, or a temp file/database. Session is simplest but uses server memory per user and needs out‑of‑proc storage on a web farm. Cache stores data with TTL and is good for ephemeral data that can be lost. Temp files are simple and durable; use App_Data or a secure temp folder and pass only a GUID in the query string.

Session["xml"] = xmlString;   // remember to remove after use
Response.Redirect("Target.aspx");

string id = Guid.NewGuid().ToString();
File.WriteAllText(Server.MapPath("~/App_Data/" + id + ".xml"), xmlString);
Response.Redirect("Target.aspx?id=" + id);

Practical notes: always remove or expire stored data after use, use GUID keys (not predictable IDs) when you pass a pointer in the URL, protect file locations from direct download, and consider compressing large XML before storage. For scalable apps prefer cache/DB/Redis over in‑memory session. Use Server.Transfer/Context.Items when you need zero extra allocation and can accept the same‑URL behavior.

Recommended Answers

All 2 Replies

if you are redirecting to another page, and chances are that querystring is too small, you can write the info to a text or xml file. then you can call it on the other page you are redirecting to. Viewstate only works on postbacks, so you have to be on the same page calling a postback. Querystring is very limited as it only allows a certain number of characters. Your only other bet is to use a session variable which can be cumbersome if using many large ones. So unless you are only using one, and not many people at one time will be using large session variables, you would need to write it to a file and read it somewhere else.

oh, you can also use a hidden form field to carry it. but it will have to redirect to the right page on submit. if your pages change frequently, then use a session or file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.