Response.Redirect with Forms Authentication redirecting to forms loginUrl

niraj zambad 1 Reputation point
  • I am using Forms authentication in C# web App.
  • When user click on a "Edit" button, he should be redirected to another page with some query string parameter.
  • It works locally but when I publish the application and drop files on Hostgator it redirects to the login url rather than the page i was expecting with query string.
  • Following is the code snippet I am using for redirection
  • Response.Redirect("EditPurchase.aspx?Supplier=" + Convert.ToString(ddlSupplierName.SelectedValue).Trim() + "&Invoice=" + Convert.ToString(ddlInvoiceNumber.SelectedValue).Trim() + "");

I am not getting why it is redirecting me to default login url. For any reason, what is the solution for this? Please guide me

A set of technologies in the .NET Framework for building web applications and XML web services.
3,238 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 47,471 Reputation points

    Is the user logged in at the point they click the Edit button? If so then the user's session information should be part of the redirect and therefore they wouldn't get a login prompt. It appears that the authentication information isn't being passed along. You can watch the browser's network traffic to confirm that the session information is getting passed along properly.

    Given you used the web forms tag I'm assuming this is a web forms app correct?

    Can you discuss the logic for your edit button? I assume it is an actual button. I also assume you have a server side event handler reacting to the button click. It does whatever and then calls the redirect. For your specific redirect to work the .aspx page needs to be in the same directory as the current page, otherwise you need to use either a virtual path or resolve the full URL first.