Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2008, 12:10 AM
Authorized User
 
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Response.Redirect does not work

Hi,

I have faced a problem with response.redirect.

There is a basic web application. The response.redirect works on local server. However, when I deployed the application on the main server, the response.redirect does not work and it just refreshes the page. The problem also exists for the Menu control. The menu navigation works on local machine but not on the main server. Could you please tell me how can I fix it.

 
Old November 28th, 2008, 11:13 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Can you show me the code you are using to Redirect to another page?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old November 28th, 2008, 10:34 PM
Authorized User
 
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's a very basic code.

protected void btnLogIn_Click(object sender, EventArgs e)
{
    /*User objUserBusiness = new User();
     objUserBusiness.UserName = txtUser.Text;
     objUserBusiness.PassWord = txtPass.Text;
     if (objUserBusiness.UserLogIn(objUserBusiness))*/
          Response.Redirect("Default.aspx");
     /*else
          lblIdPass.Text = "Invalid Username or Password.";*/
     }

protected void btnNewUser_Click(object sender, EventArgs e)
{
      Response.Redirect("CreateUser.aspx");
}


 
Old November 29th, 2008, 09:54 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The code looks good. Are you sure the target page is simply refreshing and not being redirected back to from either CreateUser.aspx or Default.aspx?

Do you have an code in your page load that would cause the request to be terminated?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old November 29th, 2008, 09:40 PM
Authorized User
 
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

After running response.redirect, The URL in address bar shows the address of the next page, but the page that is shown is the first page.

I have used some validation controls.

 I also need to mention that I used Server.Transfer, it worked but again in next page the Menu (standard asp menu control) does not work. I mean by selecting each item from menu, it is supposed to get redirected to a particular page. However, nothing happens.


 
Old December 1st, 2008, 04:50 AM
Authorized User
 
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I could find a solution by making a comment for authorization section of the web.config as follows:

1 <authentication mode="Forms">
2 <forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All"/>
3 </authentication>
4 <authorization >
5
6 </authorization>

It solved the problem and pages are redirected properly by response.redirect. Before I state the second problem, Could you please tell me whether it was an appropriate solution?.

Second Problem: I could send email based on the following code on local server.

MailMessage mailMSG = new MailMessage();
mailMSG.Body = "........";
mailMSG.To = "xyx@domain.edu.au";
mailMSG.Subject = "Your Login details";
try
  {
     SmtpMail.Send(mailMSG);
  }
  catch (Exception ex)
  {
     Response.Write("Failure in sending email:" + ex.ToString());
     return;
   }

However, this code fails on main server (works on local server) and gives me the following error

"Failure in sending email:System.Web.HttpException: At least one of the From or Sender fields is required, and neither was found. ---> System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x8004020D): At least one of the From or Sender fields is required, and neither was found. --- End of inner exception stack trace --- at
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags,
Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Type.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture) at System.Web.Mail.SmtpMail.LateBoundAccessHelper.Cal lMethod(Type type, Object obj, String methodName, Object[] args) at
System.Web.Mail.SmtpMail.LateBoundAccessHelper.Cal lMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.SmtpMail.LateBoundAccessHelper.Cal lMethod(Object obj,
String methodName, Object[] args) at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMes sage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at CCRD.LogIn.btnNewUser_Click(Object sender, EventArgs e) in C:\Documents
and Settings\bpazand\My Documents\Visual Studio 2008\Projects\CCRDDebug\CCRDDebug\LogIn.aspx.cs:li ne 47"


Could you please tell me why this error happens?

 
Old December 1st, 2008, 09:42 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Whether or not it is appropriate depends largely on how your application is setup. I typically see the <deny users> code, as you have provided, inside of child web.config's in which a developer wants to restrict access to only users who have logged in.

Try adding a From value to correct your second error.

hth.
-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old December 2nd, 2008, 01:52 AM
Authorized User
 
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help, I added mailMSG.From, but the problem still exist. These errors are very strange. Do you think I need to talk to admin to re-install IIS on main server?






Similar Threads
Thread Thread Starter Forum Replies Last Post
response.redirect sarah lee ASP.NET 1.0 and 1.1 Basics 1 October 27th, 2006 08:57 AM
response.redirect ava_h .NET Framework 2.0 0 October 18th, 2006 10:21 PM
response.redirect crmpicco Classic ASP Basics 3 February 9th, 2005 01:50 AM
Response.Redirect dhborchardt Classic ASP Basics 4 June 16th, 2003 05:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.