dimensionav
asked on
How to use response.redirect in a custom class
HI
I am using this code inside of a BLL Class:
Try
smtp.Send(correo)
HttpContext.Current.Respon se.Redirec t("pedido_ completado .aspx")
Catch ex As Exception
'MsgBox("ERROR: " & ex.Message)
HttpContext.Current.Respon se.Redirec t("Error: " & ex.Message)
End Try
And everything is working pretty well (the mail is sent) except for the fact that when the line with the httpContext is executed appears a web page that informs "IE cannot show the page", just if the internet connection was lost.
¿Any ideas?
Thanks
I am using this code inside of a BLL Class:
Try
smtp.Send(correo)
HttpContext.Current.Respon
Catch ex As Exception
'MsgBox("ERROR: " & ex.Message)
HttpContext.Current.Respon
End Try
And everything is working pretty well (the mail is sent) except for the fact that when the line with the httpContext is executed appears a web page that informs "IE cannot show the page", just if the internet connection was lost.
¿Any ideas?
Thanks
ASKER
HI Juan
I have tried but didn´t work
I have tried but didn´t work
Hi dimensionav,
Can you please tell me what's the path for "pedido_completado.aspx", relative to the root folder?\
The error you are getting is because the file is not found, so we need to make sure that the path is corect.
Can you please tell me what's the path for "pedido_completado.aspx", relative to the root folder?\
The error you are getting is because the file is not found, so we need to make sure that the path is corect.
add system.web reference in your class and use this
HttpContext.Current.Respon se.Redirec t("Your page")
HttpContext.Current.Respon
added to above try this to get url of your application
remoteUrl= ParseURL(context.Request.U rl.Absolut eUri);
and add your page name with string manipulation
remoteUrl= ParseURL(context.Request.U
and add your page name with string manipulation
ASKER
Juan:
the path is the root app folder, and the BLL class files are inside App_Code/BLL
BondinASP, These are my class references:
Imports System.Web
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Services
Imports System.Web.Services.Protoc ols
Imports System.Collections.Generic
Imports DAV.TiendaEnLinea.v1.DataA ccessLayer
And this is the way I am calling response:
Try
smtp.Send(correo)
HttpContext.Current.Respon se.Redirec t("pedido_ completado .aspx")
Catch ex As Exception
HttpContext.Current.Respon se.Redirec t("Error: " & ex.Message)
End Try
the path is the root app folder, and the BLL class files are inside App_Code/BLL
BondinASP, These are my class references:
Imports System.Web
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Services
Imports System.Web.Services.Protoc
Imports System.Collections.Generic
Imports DAV.TiendaEnLinea.v1.DataA
And this is the way I am calling response:
Try
smtp.Send(correo)
HttpContext.Current.Respon
Catch ex As Exception
HttpContext.Current.Respon
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> the path is the root app folder, and the BLL class files are inside App_Code/BLL
right you need to replace this App_Code/BLL with your path .. suppose your page inside xyz foler so it should be ( inplace of App_Code/BLL) xyz/yr pagename ..
right you need to replace this App_Code/BLL with your path .. suppose your page inside xyz foler so it should be ( inplace of App_Code/BLL) xyz/yr pagename ..
moseack,
Using the HttpResponse object from a class is perfectly fine. I still think that the problem is that the path is incorrect, so, as you suggested, Fiddler is a good idea.
Using the HttpResponse object from a class is perfectly fine. I still think that the problem is that the path is incorrect, so, as you suggested, Fiddler is a good idea.
BondinASP,
But the page is in the root folder, so both HttpContext.Current.Respon se.Redirec t("pedido_ completado .aspx") or HttpContext.Current.Respon se.Redirec t("~/pedid o_completa do.aspx")s hould work.
But the page is in the root folder, so both HttpContext.Current.Respon
ASKER
I have tried resolving the URL trough the GUI layer and it worked, so I´ll try fiddler tomorrow.
I really appreciate your help guys!
I really appreciate your help guys!
dimensionav,
What happens if you go to the browser and manually type http://yoursite/pedido_com pletado.as px? Do you get the same IE error page?
What happens if you go to the browser and manually type http://yoursite/pedido_com
ASKER
it works, because pedido_completado.aspx is basically an advice that the email has been sent to the user´s account.
Then I have to say I'm lost, added to the fact that you say it's working from the GUI :).
I use Response.Redirect from my classes and never had this problem, and, besides, there is no reason for having it. Anyway, I'm glad you get it working!
I use Response.Redirect from my classes and never had this problem, and, besides, there is no reason for having it. Anyway, I'm glad you get it working!
Gud .. its working for you :)
ASKER
HI Guys
I really sorry because I was on travelling...
Yesterday I have downloaded fiddler but I really didn´t know how to use it with VisualStudio 2005
your help will be appreciated.
I really sorry because I was on travelling...
Yesterday I have downloaded fiddler but I really didn´t know how to use it with VisualStudio 2005
your help will be appreciated.
ASKER
Should I open a new question about using fiddler?
Regards.
Regards.
What's the location of the "pedido_Completado" web page?
If, for example, is in the root folder, it should be redirected like the following (note the ~/ at the beginning)
Response.Redirect("~/pedid
If it's inside some folder, just add the path, but make sure to have the ~ sign at the beginning. It tell asp.net to map the relative name of the web page to an absolute path.