SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to navigate from one ASP.NET page to another one (each with a visual webpart) When I click a button on the first page (in my visual webpart of course), I should navigate to the second page. But it seems I cant use Response.Redirect(...) in my c# code of the first visual webpart. Also Server.Transfer cannot be used.

Does anyone know what's wrong? Thanks! (If it isn't possible to use this, is there another way?)

What DOESN'T work:



share|improve this question

Yes you are correct. None of the above options work in Sandbox.

I got around this issue by using the JavaScript window.location = "new url" and then pushing it to the page using the ClientScriptManager.RegisterClientScriptBlock method.

share|improve this answer
I'll try this later this week, but I think this could work... – Ruben Herman Feb 24 '12 at 12:04

try Response.Redirect("your page url");

so, something like this should work for you:

protected void clearBtn_Click(object sender, EventArgs e) { Response.Redirect("your page url"); }

share|improve this answer
I said I can't use this... I guess because I'm in a sandboxed solution – Ruben Herman Jan 18 '12 at 15:04
can you post the code that you currently have? – ironman Jan 18 '12 at 15:05
No, because I don't have any. I've only got an empty function. When I try to use Response.Redirect("<my url>"), It doesn't accept the Response.Redirect as valid command – Ruben Herman Jan 18 '12 at 15:12
you can try SPUtility.Redirect() or, HttpContext.Current.Response.Redirect – ironman Jan 18 '12 at 15:17
As I thought, Response.Redirect is in the System.Web namespace. I had imported the assembly, namespace already, so I guess this is being blocked by a sandboxed solution – Ruben Herman Jan 18 '12 at 15:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.