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:




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.


  • I'll try this later this week, but I think this could work... 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"); }

  • 1
    I said I can't use this... I guess because I'm in a sandboxed solution 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 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 Jan 18 '12 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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