Url Encoding in MVC - asp.net

I am confused about what is supposed to be encoded and when and when it gets decoded. For example:
<%=Html.ActionLink("Login","Login",
new {controller="Account", returnUrl=HttpContext.Current.Request.RawUrl})%>
on the login page the address will be as follows:
/Account/Login?returnUrl=%2FPreviousDirectory
suddenly this will not take me back after filling in credentials and instead takes me to root directory. however, it was working fine before.
My question is regarding the "%2F". Is this the default behavior or did I mess something up? Does this need to be decoded?

This answer should show you how to do it.

Related

LinkedIn Profile Image missing on Authentication from App

I use REST API to share articles/posts on LinkedIn Timeline and Company pages. To do so, I authorize my LI profile with the APP for accessing the profile info. As a result, could view the profile/image of a user in the APP. Everything worked fine until, for some time now, aren't able to view the user profile image from the APP. Now, it looks like:
Previous image URL starts with(accessible): https://media.licdn.com/mpr/mprx/0_
Current image URL starts with(could not access): https://media.licdn.com/dms/image/
On accessing the image in the browser,
Help me understand what has changed with LI. Thanks.
Are you injecting the URL in same way that's escaping it? The URL recently changed and has some characters that templating engines such as Handlebars will mistakenly escape.
If you inject the URL without escaping it, it should work just fine.
Check out this documentation. https://developer.linkedin.com/docs/ref/v2/media-migration,
The problem which I was facing was the image loaded sometimes, but after some days it would give above error.
The new id will be dynamic and can change from time to time. We recommend retrieving at least once every 60 days to update your media-typed URN.
In order to fix this, I save the image, the moment it is received on to personal storage(AWS S3).

My querystring parameter continuously appear

I have a web app and i use the rewrite function for the URL. Here my sample URL:
www.mywebsite.com/oscar
It will bring the guest to www.mywebsite.com/User.aspx?blk=oscar
Everything is going fine until I realized that sometimes, I don't know why, every time my webpage do the post back, it will append the querystring into current URL. So the URL will be like this:
www.website.com/oscar&blk=oscar&blk=oscar&blk=oscar
anybody have the same experienced? please help me with your solution

OAuth 2.0 REDIRECT URI

my UpdraftPlus Backup/Restore was working and backing up to Google drive.
But now the REDIRECT URI has changed on the Google Cloud Console Side.
it should end with
/options-general.php?page=updraftplus&action=updraftmethod-googledrive-auth
however it keeps truncating after the Ampersand and shows up like
/options-general.php?page=updraftplus
any help on how to set the right URI?
I also faced the same problem yesterday. It looks like a bug of Google Cloud Console to me. I managed to solve this by using "percent-encoding" in the URL for the ampersand symbol. Ampersand symbol shall be encoded as %26. So you shall enter your url the following way:
/options-general.php?page=updraftplus%26action=updraftmethod-googledrive-auth
Another option you could try (but I don't think it will be necessary) is to swith back to the old view. It looks like that in the old interface there is no problem with ampersand. The link to the old interface is at the left bottom corner (it is quite hard to find it).
By the way I've also described this solution here (but it is in Russian :)
In the latest UpdraftPlus release, we worked around this by only having one parameter in the URL!
Best wishes,
David

Facebook like button is liking wrong url

First off, I saw similar posts already, but they weren't exactly what I am asking.
I used the Facebook Dev to create a like button for my website, stuck the code in and the the button showed up. The only issue is that it likes the wrong url when I click the button.
I'm pretty sure the issue is that I have it set to redirect automatically from mydomain.com to the most recent post. I think this is gumming up the works with the like button and causing it to like mydomain.com/mostrecentpost instead of simply liking mydomain.com.
Is there a way to correct this issue without having to get rid of the redirect (because that isn't an option)?
Sorry if that was a little wordy, wanted to make sure I explained the issue fully.
Is there a way to correct this issue without having to get rid of the redirect (because that isn't an option)?
Either don’t redirect in those cases where the user agent header of the request points to it being Facebook’s scraper;
or set the canonical URL of http://example.com/mostrecentpost to just http://example.com/ using the appropriate Open Graph meta tag. (Although that would mean you would not be able to like a single post any more, because all of your posts would just point to your base domain as the “real” website; so the first is probably the better option.)

iframed ASP actions trouble

This is actually a follow up on my previous question (link)
I've created the HttpHandler and it works fine for now, I'll add flexibility by using the querystring and session to point the post I'm making in the right direction.
The next question is as follows.
Now that I have the old page iframed as it should be, there's still the trouble of handling the postbacks (or actions) these pages trigger.
Every button action (asp form post) refers to a page that is not there (it's on the other server from which I am importing functionality).
I've tried using a url mapping to the other server but I get an error that tells me the external link is not a valid virtual directory. Hence I discarded this option.
I there anyway to keep functionality going inside the iframe?
please do ask clarification if you need it.
I got a solution from a colleague.
before passing the response string to the Iframe from the handler I use a string.replace to adjust the urls in the old site. This way they point to the old site and everything works again :)

Resources