1

I have a controller that returns a redirect and I want to add an anchor link so it goes to a specific element. The problem I'm having is the element '#' gets converted to '%23'. I've tried encoding and decoding both # and %23 but it doesn't seem to work, so I feel like I'm missing something.

The code is:

return RedirectToCurrentUmbracoPage($"?success={success.ToString().ToLower()}"+"#sentletter");

I want the result to be

?success=true#sentletter

but it ends up as

?success=true%23sentletter

Thanks

4
  • did u tried System.Net.WebUtility.UrlEncode and System.Net.WebUtility.UrlDecode? Commented Dec 15, 2016 at 17:46
  • Yes, trying UrlDecode("%23sentletter") still gives me a url with %23 in it Commented Dec 15, 2016 at 18:05
  • I don't know if this will help with Umbraco, but you could try escaping it with a '/' (i.e., +"/#sentletter) to see if that works. Commented Dec 15, 2016 at 22:35
  • That actually seems to do the opposite, it returns %2f%23sentletter Commented Dec 16, 2016 at 17:12

1 Answer 1

1

In server side you have various methods for URL encoding, this info is very useful for a encoding in server side, for cliente side you can check this info for more info.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok but this is encoding, and I believe I'm trying to do the opposite and decode

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.