1

I created new SharePoint 2013 Empty Project. I used Visual WebPart. I want to redirect from page to another page. Ex: www.google.com

SPUtility.Redirect("http://www.google.com", SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current);

When I run this page I get this error: enter image description here

URL is:

http://mainsite/sites/mysubsite/_layouts/15/http://www.google.com

How can I redirect to http://www.google.com?

1 Answer 1

2

The SPRedirect Utility is meant for internal use mainly -e.g. _layouts folder and other SharePoint specific.

For External links, rather use the more traditional HttpContext.Current.Response.Redirect

2
  • Thanks @C. Marius. It works fine. I have a new questions. When I create page with custom webpart, redirect is run. But then when I open page redirect doesn't work. What is the reason?
    – zengel
    Commented Oct 16, 2015 at 12:42
  • If you just want to use the webpart for redirecting user to other page then perhaps you can use window.location.href="full url including http" inside a window.onload function
    – HarryB
    Commented Oct 16, 2015 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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