Boardy
Boardy

Reputation: 36205

Add URL variables with Server.Transfer in asp.net

I am currently trying to add a variable to the url using Server.Transfer. I need to use Server.Transfer as I need to keep form post data which is why I can't use Response.Redirect.

I am using Server.Transfer("add_account.aspx?error=userNotFound"); but the variable is not being added to the URL.

Thanks for your help.

Upvotes: 3

Views: 2689

Answers (1)

Brian MacKay
Brian MacKay

Reputation: 32019

Usually with Server.Transfer, we use context to pass data around:

Context.Items["error"] = "UserNotFound";
Server.Transfer("add_account.aspx");

This is a state container like Session and Application, but it only persists for the current request and then goes away.

Upvotes: 4

Related Questions