ラベル responseredirect の投稿を表示しています。 すべての投稿を表示
ラベル responseredirect の投稿を表示しています。 すべての投稿を表示

2012年3月28日水曜日

Response.Redirect

This is the code to redirect to a new page from a GridView...

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string SeqNo = "";
string dd = "";
int ix = GridView1.SelectedIndex;

if (ix >= 0)
{
SeqNo = GridView1.SelectedRow.Cells[4].Text;
dd = GridView1.SelectedRow.Cells[1].Text;
if ( (SeqNo.Trim() != "") && (dd.Trim() != "") )
Response.Redirect(String.Format("DocketOnline.aspx?DocketDate={0}&SeqNo={1}&cn={2}", dd, SeqNo, FCaseNo));
}
}

Prior to placing the GridView in an UpdatePanel, the code above worked fine. Now clicking on the Select column, triggering the code above, gives the error:

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

How do I fix this?

All I want is to have GridView in an UpdatePanel so that paging is AJAXed...I also want the user to be able to select a command column to go to another page.

Thanks,

Jay

You would either have to:

1. on the RowDataBound register javascript to open a new window for the selected row event...

or

2. Just use a link button and set the url and targetpane properties in a column to open a new window or to navigate to the new page.

or - cancel the asynchpost prior to the redirect and then redirect (not sure this one will work though)...

Using the response.rediect in asynch the ScriptManger gets involved and things just get messy...because it intercepts everything and the response.redirect messes up the expected structure it is figuring on sending to the client for the partial page update..


Hi,

I have a user control which does not have script manager. In this user controll I input zipcode and it will populate the city state. This user control in on the main page along with other user controls. Script manager is on the main page. There is no script manager proxy. When I click on the button to populate the city state info it is populating it but whole page is refreshed instead of city and state which is inside the update panal. Does anyone have any idea whats causing this issue?

Regards,
Nepalaya


Response.Redirect should work fine during an async postback.

Response.Redirect

I have a button on updatePanel, wich has event handler and Response.Redirect in it.

It's not working.

Haw can i resolve this problem.

Thansk

Deykin:

I have a button on updatePanel, wich has event handler and Response.Redirect in it.

It's not working.

Haw can i resolve this problem.

Thansk

Updatepanel and response.redirect don't work together and they shouldn't either. If you are going to redirect the page to some where else then why even bother to use updatepanel on it for. Updatepanel's purpose is to do partial postback on the same page. Hope that helps.


Actually, Response.Redirect() is supposed to work just fine during async postbacks.

Make sure that you have the ScriptModule registered in your application's web.config file. If it's not, check out the web.config that got installled to your Program Files ASP.NET AJAX folder to see what it should look like.

Thanks,

Eilon


As I recall, someone had the same problem a while ago. It never worked unless ajax implemented it in its lastest version.

Hi

instead of using Response.Redirect try this:

ScriptManager.RegisterClientScriptBlock( lbEditDocument,typeof(LinkButton ),"TestBlock","window.open('"+ redirectUrl +"', '_top');",true );

HTH


I'm with Luis on this one. Response.Redirect has been working fine for me with the RC, and if there's some bug, I'd love to find out before RTM gets out the door.

We could use some more info here, like what exactly is happening when the button is clicked. (I guess it's not doing the redirect, but is it refreshing the page? Is it doing an async postback? What does the traffic look like when you use Fiddler or Nikhil's Web Development Helper?)

Response.Redirect - issues...

Alrighty...so I can't get response.redirect to work anymore. I found another post with a solution, but that doesn't do anything except give me javascript errors.

The given solution is to change Response.Redirect("page.aspx") into something like this:

string script ="window.location.href='" + page +"';";

Page.ClientScript.RegisterStartupScript(this.GetType(),"redirect", script,true);

When I try to do this I just get the ubiquotous "object required" javascript error. I need to be able to redirect my users...any ways to do this when using Atlas?

David

I should note that if you set your scriptmanager to

EnablePartialRendering="false"

Then response.redirect works just fine. Since I don't know much about that attribute I have set it to false for now and am still moving forward.

However, if anyone knows how to get around it when it is set to true, I would love to hear it.

Thanks,

David


I can't say for sure how to fix your redirect problem, but I know that setting the EnablePartialRendering attribute to "false" is the wrong way. This allows you page to be dynamically updated... the entire foundation AJAX programming.

hello.

well, i'm really not sure on what you're talking about.

ajax extensions do respect response.redirect and you do get a redirect in the client (of course, this means that you'll get a complete refresh on the client side).

Response.redirect - display text in same page.

Hi guys,

I am using A.aspx , B.aspx and C.aspx pages.

From A.aspx I am calling b.aspx via Ajax code. After (Check Login user from database) success status , I am tryint o redirecting to C.aspx. But

C. aspx page content is dispalying in A.aspx. It suppose to be redirec to C.aspx. What I am dong wrong here..??

any suggessions ??

hello.

well, i'mo not following you. can you be more specific?


I am trying to check the Loginuser permissions from the Database. Once he get success permission the page has to redirect to new page.
here is my Code.

Login.aspx (a.aspx) - Enter user id & pwd and click Submit then below code executes


function CheckUser()
{
if (preLoginCheck())
{ var url = serverName+"checkLogUser.aspx?userID="+ document.frmDefault.txtUid.value +"&Pwd="+ document.frmDefault.txtPwd.value;
xmlHttp = GetXmlHttpObject(ChangeHandler);
xmlHttp_Get(xmlHttp, url);
}
}


function ChangeHandler()
{ if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
{ var getData=xmlHttp.responseText;
if (getData=="Success")
{ document.getElementById("ErrorCode").innerText=" GoooooooooooooooD";
}
else
{
document.getElementById("ErrorCode").innerText=getData; //" Invalid User name /Password";
}
}
}

checkLogUser.aspx (b.aspx) - Ajax will execute this page from here itself I want to redirec to Third Page..


If (tmpUserID <> "" And tmpUserPwd <> "") Then
crapObj = New CRAPManagement
getLogInStatus = crapObj.checkLoginUserAccess(tmpUserID, tmpUserPwd)
If getLogInStatus = "Success" Then
Response.Redirect("UserCreate.aspx") --> C.Aspx
Else
Response.Write(getLogInStatus)
End If
End If

Finanl result is C.Aspx page content is displaed in Login.aspx Page.


hello.

well, if you're using asp.net 2.0, then check the authenticationservice class:

http://www.asp.net/ajax/documentation/live/ClientReference/Sys.Services/AuthenticationServiceClass/default.aspx


Hello,
I could't understand wha should I do exactly...!


hello.

well, instead of writing your own code for making the remote call and then having to build your page on the server that has server logic for authenticating a user, you'll get that for free with the service i've showed you in the previous post (it'll authenticate by using forms authentication and it'll automatically use the current defined membership provider you've set up on the server side).

Response.Redirect + Ajax ;location.href too do the same

I have to rediraect to the same page by adding a connection string

ie

'Response.Redirect("Aju.aspx?SplashFrom=0")

but i know that Response.Redirect is not Ajax compatible

So i have done the code like bellow

Protected Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

ScriptManager.RegisterStartupScript(UpdatePanel1, Me.GetType(), "redirectMe", "location.href='Aju.aspx?SplashFrom=0';", True)

End Sub

But this code also refreshes the whole page

what can i do to only update the update panel by doing a redirection?

NOTE:Button2 is inside the same update panel so i did not and ant trigger in update panel


Response.Redirect works just fine with Ajax. If you are getting errors when using it, then most likely your web.config is not set up correctly. Response.Write is not compatible with partial-page updates, but that is for totally different reasons.

Now, for what you're trying to do: Even if you use Response.Write, you are going to get a full page refresh because you are navigating to a new page. Any time you load a new page (even if you just change the querystring parameters, you are still loading a new version of the page), you are going to get a full refresh. Only when you are changing the contents of a page, such as the value of controls, can you do partial-page updates.


In that scenario, you probably shouldn't be trying to use a redirect at all (client side or server). If you need to update another UpdatePanel from Button2_Click, you could either make Button2 one of its AsyncPostbackTriggers or you could call UpdatePanel1.Update() in Button2_Click.

If that's not helpful, provide a bit more detail about what you're trying to do.


See you are redirecting to other page, So definately you can get a full refresh page.

If you change any content then it will possible to stop refresh the page


chetan.sarode:

See you are redirecting to other page, So definately you can get a full refresh page.

No, i am redirecting to same page with change in query string


As far as the client (browser) is concerned, that is a new page. It has to reload the page.


gt1329a:

In that scenario, you probably shouldn't be trying to use a redirect at all (client side or server). If you need to update another UpdatePanel from Button2_Click, you could either make Button2 one of its AsyncPostbackTriggers or you could call UpdatePanel1.Update() in Button2_Click.

If that's not helpful, provide a bit more detail about what you're trying to do.

No;my button is inside the one and only one update panel i have.

I am redirecting to the SAME page with change in query string,because i have programed to fetch data from database based on the value in query string .

If i give the value in query string it will become easy to book mark the exact page


Please listen.

Itdoes not matter that you are redirecting to the same page. Any change in the URI will cause the browser to load what it considers to be a different page. It is a new request to the server. It is still a redirect. The page will be reloaded and you will see a visible refresh... no matter what you have in updatepanels... no matter if not a single thing changed on the page. That is how it works.

If I redirect fromhttp://www.mysite.com/mypage.aspx?q=1 tohttp://www.mysite.com/mypage.aspx?q=2, even if I the content does not change and I do nothing with the querystring, it will still cause a refresh.

If you want to use the querystring parameters to allow you to bookmark specific state of the page, that's fine. Just understand that you will have a visible refresh.


To create bookmarkable URLs, use document.hash instead of document.href. This manipulates the anchor of the URL, which you can do without causing a refresh.


could you please show me an example of document.hash

Thanks in advance


I have a similar problem. I cannot Response.Redirect("newpage.aspx") or ScriptManager.RegisterStartupScript(Me.UpdatePanel1, Me.GetType(), "redirectMe", "location.href='newpage.aspx';", True) with a button inside updatepanel. Is there anyway around this?
Please help!

Response.Redirect and AsyncPostBackTrigger

I've got a "Previous" button on a webform that uses this code to take user to previous page:

Response.Redirect(Session.Item("PREVIOUSPAGE"))

I set the button as an AsyncPostBackTrigger. This error occurs when the button is clicked:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

If I change the button from AsyncPostBackTrigger to PostBackTrigger, it works fine.

Why won't this button work asynchronously? I've got 2 other buttons on the same page that are being used as AsyncPostBackTriggers with no issue.


I think it would not work because asynchronously - the Ajax enviroment is just expecting to work with the session variables of the current page, but you are trying to tell it to revert back to previous session ids with a redirect. A postback will work because it reloads or mimics a back button of the browser. Not saying it is not possible - I am wrong plenty of times - but it would make sense that that would be the behavior. You'll also get the same behavior if a session times out and the user tries to do a back button to a previous ajax enabled page.

What I would at least consider a better solution is leverage the ability with Ajax to load and unload controls dynamically. This way you can have 'paging' and still retain the benefits of the asyncrhonous enviroment.


There is an article on how to achieve that in the Scott Guthrie's blog:


http://weblogs.asp.net/scottgu/archive/2007/02/06/asp-net-ajax-goodies-documentation-download-back-button-support-new-animation-control.aspx

Juan

2012年3月26日月曜日

Response.Redirect and regular postbacks

I have an updatepanel that includes several controls, and I need to be able to do things such as export to outlook, export to excel and use fileupload controls.

To move those links outside of updatepanels would compromise my layout.

Is there anyway I can force a button to perform a classic postback if it's inside an update panel?

Thanks!Hmmm, interesting. Here's an idea. Could you have a button outside the UpdatePanel with the "visibility:hidden" style set (NOT Visible=False, btw), and then have a button inside the UpdatePanel who's onclick script is "onclick='realPostBackButton.click()". So basically when the user clicks the button inside the UpdatePanel it just triggers a trick outside of it.
thanks for the tip. i could do that. if that's the only workaround possible, then i suppose it isn't too painful.

I can't think of another way to do it, so we'll keep it our little secret. :)


My button is outside of the update pannel and I get errors trying to export to excel. It gives me the following error:

Control 'ctl00_contentPlaceHolder_GridView1' of type 'GridView' must be placed inside a form tag with runat=server.

I think this is because I am using a Master Page with the Ultrapanel. My source for exporting to excel is:

protected

void btnExportToExcel_Click(object sender,ImageClickEventArgs e)

{

Response.Clear();

Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");

Response.Charset = "";

Response.ContentType = "application/vnd.xls";

System.IO.StringWriter stringWrite = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

GridView1.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());

Response.End();

}

It fails on the RenderControl method. Any ideas?

Thanks,

Duncan


Just what the code says - the Gridview must be within a <form runat="server"> element, either in the MasterPage or in the ContentPanel.

So there is no way to export a gridview that is in an Atlas:UpdatePannel, because my understanding if exists there is will not be in a <form runat="server"> element. If you try to put the <form> element in the ContentPannel of the UpdatePannel then it will conflict with the one in the master page.


The one at the master page should be fine. Something else must be causing the problem - is the ContentPlaceHolder in the Master Page not within the form tag?

Note the SampleWebsite that's included wiht the Toolkit (DefaultMaster.master) has a form tag and the GridView's in the sample pages work correctly.


I ended up using the Interop.Excel dll to export to excel and it worked.

I couldn't get my old method to work but it doesn't appear that it was an ATLAS issue. To get rid of that particular error I had add the following override.

public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for the

}


I am getting 'Unknown Error' and no export. What is the deal?. Is it possible to use Atlas and export to Excel?
Because AJAX is not doing a full post I found that you cannot do an export to excel with Response.Write. What I had to do was save the file to the server, and then do a windows.open in my javascript OnClientClick funtion.

Response.Redirect and UpdatePanel Problem Again

I can't figure out if I'm doing something wrong, it's just how it is, or it's a bug. If I create an UpdatePanel and place a button in it and then put Response.Redirect in the button's click event, everything works as I would expect and I'm redirected to the page I specified in the event. Now, if I drop a DataList inside the UpdatePanel and then put LinkButtons that have OnCommand and CommandArguement properties inside the DataList's ItemTemplate, response.redirect won't work for those LinkButtons. It just clears the datagrid and remains on the same page.

I've read everything I can find about people having the same problems but everything I read doesn't address buttons inside a DataList. Normal buttons in the UpdatePanel work for me. I'm using Ajax 1.0 RC.

Strange. Could you share your code?

Here's what I tried, and it works fine:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void item_command(object sender, DataListCommandEventArgs e) { Response.Redirect("http://ajax.asp.net"); } protected void Page_Load(object sender, EventArgs e) { list.DataSource = new string [] { "one", "two", "three" }; list.DataBind(); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head ID="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="sm1" runat="server" /> <asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:DataList ID="list" runat="server" OnItemCommand="item_command"> <ItemTemplate> <asp:LinkButton ID="button" runat="server" Text="<%# Container.DataItem%>" CommandName="redirect" /> </ItemTemplate> </asp:DataList> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

I need to get the CommandArgument from the LinkButton, set it to a session variable and then redirect. Here is an example of my code.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:datalist id="MyList" runat="server" EnableViewState="False" RepeatColumns="4">
<ItemTemplate>
<asp:LinkButton ID="MyLinkButton" runat="server" EnableViewState="FALSE" OnCommand="My_Command" CommandArgument='<%# Eval("MyID") %>'><%# Eval("MyName") %>
</asp:LinkButton>
</ItemTemplate>
</asp:datalist>
</ContentTemplate>
</asp:UpdatePanel>
Public Sub My_Command(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.CommandEventArgs) Session("MyID") = e.CommandArgument Response.Redirect("MyDetail.aspx",False)End Sub
 
Thanks!

I haven't tried this yet, but I notice you're passing False as the second argument to Response.Redirect()... does it make a difference if you change that to true? (Or simply drop it as in my example?)

I've tried it all three ways with the same result.


I tried the following code and it seems to work for me too. Have you used Fiddler on any other trace tool to chaeck what the response is from the server?

<%@. Page Language="VB" AutoEventWireup="true" %><script runat="server"> Protected Sub LinkButton1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Session("MyID") = e.CommandArgument Response.Redirect("Default2.aspx") End Sub</script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" />   <asp:UpdatePanel ID="UpdatePanel1" runat="server" EnableViewState="False"> <ContentTemplate> <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" EnableViewState="False" RepeatColumns="4"> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("AddressID")%>' OnCommand="LinkButton1_Command" Text='<%# Eval("AddressLine1") + Eval("AddressLine2")%>'></asp:LinkButton> </ItemTemplate> </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>" SelectCommand="SELECT TOP 100 Person.Address.* FROM Person.Address"></asp:SqlDataSource> </ContentTemplate> </asp:UpdatePanel>   </form></body></html>

I finally found the problem. In my codefile I have a sub that gets called that fills the datalist in the Page_Load procedure.

As an example:

If Not Page.IsPostBackThen
 'Do some stuff if this isn't a postback UpdateMyDataListEnd If
This worked for everything *except* clicking on the LinkButtons in the Datalist. So what I did was this and it now works for the LinkButtons as well.
 
If Not Page.IsPostBackThen
 'Do some stuff if this isn't a postback
Else UpdateMyDataListEnd If

Response.redirect causes post back using Atlas


Hi,

I have a webpage with a button on it. The button is placed in an update panel. I want to redirect user to another page when the user press the button. Basically it is a save button which save user information and redirect user to another page.

I tried using response.redirect("anotherpage.aspx") but it caused post back however the button is placed under a n update panel.

Can anyone help me out? I want to save data on button click and redirect user to another page without causing post back.


Thanks.
Imtiaz

Redirect has to cause a postback, you are trying to "redirect" the user.

Firstly, all things inside an update panel cause a postback, they just go through some different steps, and only deal with events in the update panel, and only refresh the part of the page inside the panel.

So your button is designed to postback, which it does... then redirects, the update panel picks this up, and changes the browser page.

The functionality is correct.

If you want, instead of a button with a redirect, make a regular html button with a clientside event.

onclick="redirect();"

function redirect(){

location.herf = 'newURL.aspx';

}

If you call a client side method to change the location of the page, then there is no post back to the server

Response.Redirect cant worked as expected inside UpdatePanel while placed in a ModalDialog

I placed a updatepanel in a modaldialog and placed a button inside the updatepanel. when clicked on the button, something needs to be done and if necessary, the button maybe call Response.Redirect(...) to force moveing to a new URL in the same Modaldialog.

I placed " <base target='_self' " /> inside the " <head> " of the page, and the Redirect can do as expected while the button is placed outside the updatepanel. but If the button is moved inside updatepanel, the 'Redirect(...)' will always open a new window, that's is unexpected.

I tried the client script, such as ' window.location.replace(...)' also, but it acts as above. even if I placed a <input type='button' onclick='window.location.replace(..)' /> inside the updatepanle.

Is this a bug of UpdatePanel? Because the objective can be done without updatepanel.

Could you please help me?

Thank you very much.

did you try Server.Transfer instead of Response.Redirect ??


Thanks!

I had tried Server.Transfer already yesterday. but a exception is popup.

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common casuses for this error are when the respons is modified by calls to Response.Write(), response, filters, HttpModules, or server trace is enabled. .....


hi i too faced the same problem i over came it bye writing the Response.Redirect("javascript:mypopfunction()");

in response.redirect write that jave script function call write u r window code in java script to pop up this worked finre for me u also try this it will work if not let me know ao that i may further help u ok byee ALL THE BEST

Vissu


Thank you.

I write client function as follow.

<script>
function MoveToURL(newurl)
{
window.location.replace(newurl);
}
</script>

Then respond to button click event on server-side as follow :

Response.Redirect("javascript:MoveToURL('Dialog2.aspx');");

But the problem still exists. Maybe I didnt catch your real idea. Could you please give a example.


hi pass the page name webform2.aspx as a parameter to function in java script

ieeee....

<script>
function MoveToURL(newurl)
{
var reportWin=window.open(newurl,"options",'resizable=yes,scrollbars=yes,width=780,height=650,left=150,top=50,status=yes')


}
</script>

Then respond to button click event on server-side as follow :

string myaspx="Dialog2.aspx'";

Response.Redirect("javascript:MoveToURL('"+myaspx+"')");

hope this helps...

Vissu


it functions as before. a new window is open unexpected.

it seems all the script executed from inside an updatepanel results in the same. despite of :

window.open

window.location

Response.Redirect


i doing the same thing i send but it is working fine for me i don't know why its not working for u any way try u will defnitly get answer for that ALL THE BEST

Vissu


The problem is that you're trying to do something that requires an HTTP response context to work, in a partial postback which does not return in an HTTP response.

Use something like this:

ScriptManager.RegisterStartupScript(this,this.GetType(),"redir","document.location = 'NewPage.aspx'",true);

hi this will work look at it

ScriptManager.RegisterStartupScript(this,this.GetType(),"EmpReports","javascript:ReportPage('" + PName +"')",true);

write this in C# Code

Vissu


this worked as above. the problem still exists.

Please note that the UpdatePanel is in a ModalDialog.

For the normal window, response.redirect can work correctly.

For the ModalDialog, if updatepanel is not used, the redirect can work correctly by adding <base target='_self' /> to <HEAD>. Once updatepanel is used in modaldialog, the redirect opens always a new window.


Without more much better solution, now I just use the following code:

Replace 'Response.Redirect' with a client script to show a new modal dialog from current dialog.

string script = "window.showModalDialog('Dialog2.aspx'); window.close();";
ScriptManager.RegisterStartupScript(this, this.GetType(), "OpenNewDialog", script, true);

this solution will launch too much dialog window. So I still sincerely hope someone can help me solving this problem ina better way.

Thanks.


You can't do Response.Write() while using an AJAX

See for more details..

http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx


I am using Response.Redirect, not Response.Write, and Response.Redirect can work correctly with an updatepanel inside a normal window. In this case, the new page can be loaded in the same window. Once Used with an updatepanel inside a modal dialog, the new page is loaded always in a newly opened window. The key difference is between normal window and modaldialog.


What you are trying to do is not possible with ModalPopup extender. The ModalPopup usually binds with an Asp Panel renders as Div (Not a Window). So playing with the url Response.Redirect, window.location will always opens a new page.

Response.Redirect cannot be called in a page callback error message.

Hi. I'm using the Dundas Chart Controls in VS 2005. These controls are built utilizing AJAX. I have a basic page with a dundas chart control containing a funnel chart. The funnel contains Quotes, Sales Orders and Invoices. When the user clicks on the control, I want to determine whether they clicked on Quotes, Sales Orders or Invoices and transfer to the appropriate Details Page. I've got the code working to determine which transaction type they clicked on; but, I get the "Response.Redirect cannot be called in a page callback." error when the page tries to redirect. Note: I get a similar issue if I try server.transfer.

Suggestions?

Here's my code:

Dim hitTestResultAs Dundas.Charting.WebControl.HitTestResult = Chart1.HitTest(e.X, e.Y)If Not (hitTestResultIs Nothing)Then Dim clickedAs Dundas.Charting.WebControl.DataPoint = hitTestResult.Series.Points(hitTestResult.PointIndex)Select Case hitTestResult.PointIndexCase 0 Response.Redirect("COQuotes.aspx")Case 1 Response.Redirect("COOrders.aspx")Case 2 Response.Redirect("COOrders.aspx")End Select End If

Since it's a partial postback that is occuring, you can't use Response.Redirect. You need to do a full postback in order to redirect or use a different method. See the last message in this post:http://forums.asp.net/t/1165851.aspx

-Damien


I have no control over the callback. It is being executed by the Dundas Control. I tried implementing the code with the RegisterClientScript, as below. But, nothing happens...

Dim hitTestResultAs Dundas.Charting.WebControl.HitTestResult = Chart1.HitTest(e.X, e.Y)If Not (hitTestResultIs Nothing)Then Dim clickedAs Dundas.Charting.WebControl.DataPoint = hitTestResult.Series.Points(hitTestResult.PointIndex)Select Case hitTestResult.PointIndexCase 0 clientRedirect("COQuotes.aspx")Case 1 clientRedirect("COOrders.aspx")Case 2 clientRedirect("COOrders.aspx")End SelectSub clientRedirect(ByVal URL)Dim jScriptAs String jScript =String.Format("document.location.href ='{0}');", URL) ClientScript.RegisterClientScriptBlock(Page.GetType(), "redirect", jScript,True)End Sub


GiveRegisterStartupScript a try. Seehttp://blogs.ittoolbox.com/c/coding/archives/registerclientscriptblock-and-registerstartupscript-17321 for some more info.

-Damien


Tried RegisterStartupScript, still nothing happens.

Jennifer


Hi,

I'm not familiar with dundas chart but is there no way to setup a href on a chart element during rendering? I would have thought this would be a standard feature.

Back to your Response.Redirect problem. When you get a response from the callback can you control the client-side callback function? If so you could use the cookie method as in the last post. If you have no control over the client-side callback function I very much doubt your going to be able to add the functionality you require.

One minor point, if your re-directing anyway whay do you need to use ajax, you could do a page post back when clicking the chart, do your logic and then redirect. To the user the behavior would seem exactly the same as your moving to a different page anyway.

Cheers Si


You won't be able to use Response.Redirect() or Server.Transfer() in a callback, check if the control has a client event you can use instead, if that event exists you could use window.location.replace("OtherPage.aspx"); using JavaScript from the client to move to another page.

response.redirect cannot be called in a callback call

And I really need to.. anyone can tell me the reason why? The problem is that in the callback I call some session variables and if the session has expired, instead of throwing an exception, I want to redirect the user to the login page.

Any idea will be awesome!!

Thanks

check for session before use it

Session["Value"] ! = null

Also you can redirect the user to the login page for example if the session has been expired by handling Session_End method in the Global.asax


Can you post the code of your callback function?


Well... maybe I need to explain myself better. I have a base class from which all my ASPX file inherit; in this class I have this code:

1 protected override void OnPreInit(EventArgs e)

2 {
3 if (Context.Session !=null)
4 {
5 if (Session.IsNewSession)
6 {
7 string cookieHeader = Request.Headers["Cookie"];
8 if (!String.IsNullOrEmpty(cookieHeader) && cookieHeader.IndexOf("ASP.NET_SessionId") >= 0)
9 {
10 if (Page.IsCallback)
11 {
12 //This is where I need to redirect the user in the callback
13 }
14 else
15 {
16 Response.Redirect("~/SessionExpiredPage.aspx",true);
17 }
18 }
19 }
20 }
21
22 base.OnPreInit(e);
23 }

So I basically check if the session has expired and if so, I redirect the user to a session expired page. I want to do it in the same class, but I have not found a way to stop the callback, redirect or anything... any advice is welcome.

Thanks in advance


What error are you getting?

hi, i'm assuming your talking about a page method callback? if so I don't think there is anyway to re-direct the whole page in the way you describe. You would just end up re-directing the callback call if you get what I mean. Your gonna have to handle this on the client-side

Couple of ways you could acheive what your trying to do.(these are untested theories)

if you using an updatepanel, if the session has timed out, add this to the response

string script = string.Format("document.location.href = '{0}');","loginPage.aspx");

scriptManager.RegisterClientScriptBlock(Page,typeof(Page),"redirect", script,true);

if your using a page method callback it's a little more difficult

if the session has expired you could use a cookie

HttpCookie objCookie = new HttpCookie("MyCookie");
Response.Cookies.Clear();
Response.Cookies.Add(objCookie);
objCookie.Values.Add("sessionExpired","true");
DateTime dtExpiry = DateTime.Now.AddDays(1);
Response.Cookies["MyCookie"].Expires = dtExpiry;

then in your client-side callback function, check for the existance of this cookie and re-direct using document.location.href (but be sure to clear the timeout cookie)

Cheers Si


thanks for the answer... and you're right.. there is no way to make that callback redirect...

Response.redirect causing error when used with ajax

Hi Guys,

I hope somebody can help me with my problem, I'm fairly new to ajax.I have a datalist in my app which has a clickable button which directs the user to a subroutine....


1Sub PhotoCommand(ByVal objAs Object,ByVal EAs DataListCommandEventArgs)2Dim CommandAs String = E.CommandName3Dim ArgumentAs String = E.CommandArgument45If Session("UserID")Is Nothing Then6 Response.redirect("index.aspx")7End If8End Sub


This works fine when not in a updatepanel and the updatepanel worksfine without the redirect in it, but when you use the two together andclick the button you get the following error in an alert box.

"Sys.Webforms.PageRequestManagerParserErrorException:The message received from the server could not be parsed. Common causesfor this error are when the response is modified by calls toresponse.write(), response filters, HttpModules or server trace isenabled

Details:Error parsing near'

<!DOCTYPE ht'"

Anyone got any idea why this might be ?

Jon

Hi,

Sorry guys, just found out what the problem was by searching the forum a bit more. FOr the sake of anyone else with the same problem, I had forgotten to add the following to my web.config...

<httpModules>

<addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</httpModules>

Response.Redirect doesnt work with UpdatePanel in Beta 1

I have a page with an update panel that contains a few buttons that need to be able to redirect to another page. The script manager is located on a master page.

Every time one of those buttons are clicked, i get one of two errors:

    If the button is inside of a gridview, i get this error:
    Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
    If the button is NOT inside of a gridview, i get this error:
    Sys.WebForms.PageRequestManagerParserErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 302

Here's a test aspx page that I set up:

1<%@dotnet.itags.org. Page Language="VB" title="Untitled Page" MasterPageFile="~/main.master" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>2<%@dotnet.itags.org. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="ajax" %>3<asp:Content ID="Content1" ContentPlaceHolderID="plhContent" Runat="Server">4 <ajax:UpdatePanel runat="server">5 <ContentTemplate>6 <asp:Label runat="server" ID="lblTime" /><br />7 <asp:Button runat="server" ID="btnRefresh" Text="Refresh" /><br />8 <asp:Button runat="server" ID="btnRedirect" Text="Redirect" /><br />9 <asp:LinkButton runat="server" ID="lnkRedirect" Text="ASP Linkbutton" /><br />10 <a href="http://www.google.com/" title="test redirect">HTML Hyperlink</a>11 </ContentTemplate>12 </ajax:UpdatePanel>13</asp:Content>
And here's the codebehind:
1PartialClass test2Inherits System.Web.UI.Page34Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load5 lbltime.Text = now()6End Sub78 Protected Sub btnRedirect_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnRedirect.Click9 Response.Redirect("http://www.google.com/",True)10End Sub1112 Protected Sub btnRefresh_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles btnRefresh.Click13 lblTime.Text = Now()14End Sub1516 Protected Sub lnkRedirect_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles lnkRedirect.Click17 Response.Redirect("http://www.google.com/",True)18End Sub19End Class


The LinkButton causes the same error, so it's not just limited to the button control. It looks like it affect anything that posts back to the server and causes a redirect.

Thanks for any help you can give me!

We found this out today too. The fix is to pass a location.href back to user.

ScriptManager.RegisterStartupScript(pnlYourUpdatePanel,this.GetType(),"redirectMe","location.href='blah.aspx';",true);

Sorry it is in C#... Hope this helps.


hello.

i've just built a sample project with the following code:

master page:

<%@. Master Language="VB" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:scriptmanager runat="server" ID="manager" />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

page:

<%@. Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<script runat="Server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblTime.Text = Now()
End Sub

Protected Sub btnRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRedirect.Click
Response.Redirect("http://www.google.com/", True)
End Sub

Protected Sub btnRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
lblTime.Text = Now()
End Sub

Protected Sub lnkRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRedirect.Click
Response.Redirect("http://www.google.com/", True)
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:updatePanel runat="server" id="panel">
<contenttemplate>
<asp:Label runat="server" ID="lblTime" /><br />
<asp:Button runat="server" ID="btnRefresh" Text="Refresh" /><br />
<asp:Button runat="server" ID="btnRedirect" Text="Redirect" /><br />
<asp:LinkButton runat="server" ID="lnkRedirect" Text="ASP Linkbutton" /><br />
<a href="http://links.10026.com/?link=http://www.google.com/" title="test redirect">HTML Hyperlink</a>
</contenttemplate>
</asp:updatePanel>
</asp:Content
everything is working here with the beta extensions. are you sure you've set up web.config correctly?


Luis,

When looking at the XMLHttpResponse google.com is being returned which is causing the parser error. Not sure how you are getting this to work with the Beta release?? Also, not sure how config would cause this?

Matt


hello.

well just recalled one problem i've seen before where the users updated the prefix but left it pointing to the old ctp dll which was still in the bin folder and it just blow everything apart. btw, here's what i'm getting back from the server side in response to a click over the redirect button (2nd one from the top):


22|pageRedirect||http://www.google.com/|


Luis Abreu:

everything is working here with the beta extensions. are you sure you've set up web.config correctly?

I think I do. I have a Microsoft.Web.Extensions assembly in the web.config. Is there aything else I need?

1<compilation debug="true" strict="false" explicit="true">2 <assemblies>3 <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>4 <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>5 <add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>6 </assemblies>7</compilation>


Luis Abreu:

well just recalled one problem i've seen before where the users updated the prefix but left it pointing to the old ctp dll which was still in the bin folder and it just blow everything apart.

I did delete the old CTP DLL, and added the new assembly registration to the top of the page:

1<%@. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Web.UI" TagPrefix="ajax" %>2

hello again.

can you confirm the response you're getting back from the server? is it similar to the one i've shown before?


How do I access the server response information?

hello.

use fiddler. if you're using ie, you must create a site in IIS and then use the name of the machine (http://machinename/site). if you're using firefox, configure it so that it uses a local proxy (127.0.0.1 port 8888 if i'm not mistaken).


It is definitely in the config. Again... good call Luis... you are missing these values in your config and this should cure the problem.

<httpModules><add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></httpModules>
Thank Luis for that one. =)
P.S. That is under httpHandlers

That worked! You guys are awesome.


Thanks!


Thanks - Guys!

I was experiencing the same problem in Beta 2, which this solution apparently resolved that issue.


Hi Guys!

I Got the Same error in my current project. I cant redirect to another page from inside the UpdatePanel. Finally I saw this forum and got a wonder result and answer. Its really amazing and thanks a lot for u all guys..

rgds,

Senthil

Response.Redirect doesnt work with AJAX Extensions Beta 1 (Atlas)

I was using the July Atlas CTP and I decided to give the new AJAX Extensions beta a try... now anytime I call Response.Redirect() when I handle an event for a control that is inside an UpdatePanel I get an error that says, "Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed." This happens regardless of whether I'm doing a partial postback or a regular postback as long as the control that caused the event is inside an UpdatePanel.

I found it odd that ScriptManager.IsInAsyncPostBack == true when I clicked a button that wasn't assigned to an AsyncPostBackTrigger... I'm assuming that that probably has something to do with why the Response.Redirect() didn't work. (Yes, I did verify that UpdatePanel.UpdateMode was set to Conditional.)

This is all fine with me I guess as long as there's another way to redirect to another page in server side code. Anyone know what I need to do?

Thanks,
Jon

Calling Response.Redirect() during an async post is supported. Make sure you have the ScriptModule on web.config for this work:

- Federico

  
 <httpModules> <add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </httpModules>

Right after I posted the original message I noticed that I had put the <httpModules> stuff in the wrong place. :)

Response.Redirect doesnt work when the button is inside an ajax updatepanel

Hello,

I am getting the following error whenever I click a button inside an ajax updatepanel and it tries to Response.Redirect from the code behind.

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near'

<!DOCTYPE html P'

I wasn't sure if it was my page not being correct or if it was something else. So I created two basic test pages test.aspx and test2.aspx. I click a button on text.aspx and it is supose to redirect to test2.aspx. This is a basic example giving the exact same error. So hopefully if I can get a resolution to this I could fix my real asp.net page. Thanks, Risso

Here is the test.aspx code:

<%

@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="test.aspx.cs"Inherits="test" %>

<%

@dotnet.itags.org.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TagPrefix="asp" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><linkhref="css/modaldialog.css"rel="stylesheet"type="text/css"/><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><div><asp:ScriptManagerID="ScriptManager1"runat="server" ></asp:ScriptManager><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:ButtonID="Button1"runat="server"OnClick="Button1_Click2"Text="Button"/></ContentTemplate></asp:UpdatePanel></div></form>

</

body>

</

html>

HERE IS the Code behind code:

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

public

partialclasstest : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid Button1_Click2(object sender,EventArgs e)

{

Response.Redirect(

"~/test2.aspx");

}

}

HI.

Try to useServer.Transfer.


I did server.transfer shown below. It still gives the same error message. I put a breakpoint in the test2.aspx to see if it makes it to that pages_load event and it does, but the browser throws the exact same error message as listed in the first post. Any other ideas?

protectedvoid Button1_Click2(object sender,EventArgs e)

{

Server.Transfer("~/test2.aspx");

}


Hi, u must knwo that Response.Redirect and Server.Transfer work inside UpdatePanel.

can u share us the detail of the error that u have.


I tried your code and one of my own and it appears to be fine. Before you start beatin your head against the wall, try this...

This a must read from Eilon Lipton's Technical blog on Microsoft ASP.NET and ASP.NET AJAX when trying to solve PageRequestManagerParserErrorException errors!

http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx?CommentPosted=true#commentmessage A


Eilon Lipton's tips are great, I just add some more: Test "test2.aspx" for any invalid html markup, also test the response with fiddler.

Ok,

I found out were it is happening, but now I am not sure how to solve it since what I have to remove is also needed. I found that it was inside the web.config. I'm adding 2 httphandlers that were needed to fix other AJAX issues. I don't recall exactly what those issues were because this is a big application and it was a while back. I do remember these were needed to fix other ajax problems though. I do not want to remove these and have them break other ajax controls/tools. Anyone know a work around for this. I do know now that these httpHandlers are what is causing my Response.Redirect() issue in my updatepanel.

I removed the following lines from my web.config for it to work.

<

httpHandlers>

<

removeverb="*"path="*.asmx"/>

<

addverb="*"path="*.asmx"validate="false"type="Microsoft.Web.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<

addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/>

</

httpHandlers>

Risso


Shoot, I just realized those were needed for the Ajax to work in IE. And by me removing those lines from the web.config it just does a normal postback and not an asynchronous call. That is why it worked for me. So really nothing has changed. I am back to nothing on why the response.redirect() doesn't work. You guys mentioned that you took the code and were able to get the response.redirect() to work. I'm not sure what in my environment could be any different. I'm running this off of localhost and I do not have IIS running.

Yeah. Have you tried a new website as ajax supported web? I tried both an iis and casini version of the test. What version of vs are you running?


Aesop:

Yeah. Have you tried a new website as ajax supported web? I tried both an iis and casini version of the test. What version of vs are you running?

Agree, use vs to create a new "ASP.NET Ajax-Enabled Web Site" or "ASP.NET Ajax CTP-Enabled Web Site", and use the web.config of the new site as a template, so carefully migrateyourweb.config into the template.

You can get a template web.config also from a similar path:

C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025

C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Futures January CTP\v1.0.61025


Yes, I got it to work!! Thank you for your persistent responses. I did what you both recommended and started a new Ajax Application and pulled its web.config to compare to mine and went line by line with testing each line and found what I was missing. My web.config didn't have

<

httpModules>

<

addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</

httpModules>

Risso


Hi Rissoman,

Thanks your post. I have the problem like you. I took 2 days to find why I always take the PageRequestManagerParserErrorException. Well, I am upgrading the website, and missing the <httpModules>

Thanks again,

HUH


Thanks to everyone who posted about this. You've just saved me a lot of time and effort! Thanks!


HI,

Thanks a ton .for that code..

regards

Delia Joe

Response.Redirect from UpdatePanel causes full refresh

I noticed that when I redirect to another page from within an update panel, the page fully refreshes (may be that's by design?).

How can I prevent this from happening?

Thanks.

you can not prevent this, this is the way any web sites works. When you say response.redirect, you are instructing the browser to make a fresh call to particular aspx page.


rmaiya:

you can not prevent this, this is the way any web sites works. When you say response.redirect, you are instructing the browser to make a fresh call to particular aspx page.

that is right.

If you are trying to only update the panel then try something like, updatePanel1.update();, or if you want to load a new page inside the panel try putting an iframe inside the panel


What is considered as best practice?

For example, if you click on the above links (such as "Learn", "Downloads", "Ajax"...) on this page, how do they ensure that that the header and footer elements of the page don't "blink"?


As they are different pages, I do want to do a response.redirect to keep the URL's friendly, but at the same time, I would like my header and other static elements not refresh each time. Do they use partial page caching to achieve this?

Response.Redirect in AJAX

I have a button in Update panel.

On button click I have written

Response.Redirect("InterMediateMsg.aspx", False)

When I executes the application I got the Error..

Sys.WebForms.PageRequestParserErrorException:The message received from the server could not be parsed.

How should I implement Redirection in AJAX.

Hi,

in the onclick (client side!!) you just place self.location.href='urltogoto'. Don't use AJAX for something like that but plain old javascript.

Grz, Kris.


Response.Redirect should work fine during an async postback. Try dropping the "False"... I'm not sure if you can use that option.


Actually I have performed server side coding( Database operations) on button click .

After the successful operation I want to navigate to another page.

How could I do it.


I have tried it by dropping false.

Actually this second parameter specifies whether I want to terminate execution of current page or not.

Is there any effect of browser.

I am using IE 6.0


Make sure that you have buffer set to false on the page from which you wish to redirect - otherwise output will already have been streamed out to the client, and things will go horribly wrong!

This cost me quite a bit of investigation a while ago..!


i think this error may be because it is trying to process a redirect within the update panel. assuming you use a trigger for the updatepanel and button, set it to a asp:PostBackTrigger instead of a asp:AsyncPostBackTrigger, this will send your page into a full postback, which may solve your problem (i haven't tested it).


I try the way you suggest, and its work !Wink


glad to help!Smile


Thnx ChrisCicc ,

It's working.

I have set the Trigger for button to PostBack and it worked.

Response.Redirect in a PostBack causes javascript error => workaround here

There's a problem in Atlas when calling a Response.Redirect on a postback (and the ScriptManager uses "EnablePartialRendering=true"). E.g. doing a Response.Redirect("otherpage.aspx") from the button-click event code.

There's a workaround, however.

Instead of doing:

Response.Redirect("otherpage.aspx");

do this:

Page.ClientScript.RegisterStartupScript(
this.GetType(), "redirect",
"window.location.href='otherpage.aspx';",true);

I wrote a custom httpmodule (acquirerequeststate event) that needed to do a response.redirect in certain cases. This threw the "unknown error" on atlas pages. I added "false" for the endReponse parameter and it works fine now. Response.Redirect("page.aspx",false).

thanks

Response.Redirect in Asp.net AJAX

Hi All,

I Developed a project in as.net with Asp.net Ajax... i used Response.Redirect several time in my web project with and without script manager... and its worked fine...
but some tells me...this is not recommended to use Response.Redirect in asp.net AJAX....and when i will deploy on Production server... there may be chance of some error.............

So please give your opinon....
Thanks
SajjadPerhaps you are confusing this with Server.Transfer. There should be no issues with Response.Redirect.
R u 100% sure...
and what issue with Server.Transfer....

REsponse.Redirec will not cause any issues if you invoke it from CodeBehind pages.

I have worked with one developer who instantiated the Page object, and tried to use the page object.REsponse.REdirect() and that failed - as it should.