I am getting the error unable to evaluate the expression because the code is optimized or at the top of the call a basic frame Stack's
When executing the line
the server. Transfer ("Payment.aspx? Vpc_ChannelId = 2", true);
So this answer is told & amp;
I have changed my code in
protected Zero Page_load (Object Sender, EventArgues E) {try {UserContext conObj = new UserContext (); HttpContext CurrContext = HttpContext.Current; If (! IsPostBack) {// code} and {string userContext = hdnContextObj.Value; ConObj = JsonConvert.DeserializeObject & lt; UserContext & gt; (User Contex); CurrContext.Items.Add ("Reference", CoWoob); Try {Server.Transfer ("Payment.aspx? Vpc_ChannelId = 2", true); } Hold (threadbortextsit xObj) {} finally {server} Transfer ("Payment.aspx? Vpc_ChannelId = 2", true); }}} Hold (exception xObj) {response. Type ("Exception:" + xObj.Message); }}
I still get the same exception in the catch block
Along with this, I have been told here that I have written the code Server.Execute
But it did not, instead it simply redirects to Payment.aspx
page to refresh.
The exception is raised because the thread running the operation is forced to terminate in many places due to the transfer. As such, it is safe to ignore this exception because your suggested tips are suggested.
You can catch the exception by catching the exception and ignoring the exception.
try {server}. Transfer ("Payment.aspx? Vpc_ChannelId = 2", true); } (ThreadAbortException) {// exception has been ignored: Thread Abort = Stop processing on current page}
Alternatively, as the article suggests, you < Code> Server.Execute instead.
To resolve this problem, use one of the following methods:
For response
, HttpContext.Current.ApplicationInstance.CompleteRequest
method to execute the code for eventApplication_EndRequest
instead ofResponse.End
.Response For redirection
, an overload,response. Use redirects (string URL, boolean and response)
that pass. For example:
response
for parameterfalse to suppress the internal call response. Redirect ("nextpage.aspx", Incorrect);
If you use this solution, the code following the Response.Redirect is executed.
Transfer to the server
, instead use theServer.Execute
method.
// explanation server.exequate
the doctor has server .Execute explained the use of
. It is important to remember that this is not a redirect, this function works like a call. Therefore any code will also be executed after the call. If you do not want to execute the code, you can use a return
, or response.
.
In the example of OP, its code can be viewed by server.execute
using protected Zod Page_load (object sender, EventArgues E) This is how time some user {user contacts CONOX = CONOBEZ = new user context (); HttpContext CurrContext = HttpContext.Current; If (! IsPostBack) {// code} and {string userContext = hdnContextObj.Value; ConObj = JsonConvert.DeserializeObject & lt; UserContext & gt; (User Contex); CurrContext.Items.Add ("Reference", CoWoob); Server.Execute ("Payment.aspx? Vpc_ChannelId = 2" is true); Rispans.and (); // return; }} Hold (exception xObj) {Response.Write ("exception:" + xObj.Message); }}
Comments
Post a Comment