0

So I need the following: When someone navigates to a certain page then it checks if it's the facebook Like crawler. If it's true then it shows the page normally (with the opengraph tags and everything).

If it's false (so the user is just a normal user) it should redirect to a specific external URL.

This is my code so far:

        NotebookModel notebookmodel = db.NotebookModels.Find(id);
        var isFacebook = Request.UserAgent != null && Request.UserAgent.Contains(Config.FacebookUA);
        if (!isFacebook)
        {
            return Redirect(notebookmodel.Url);
        }
        return View(notebookmodel);

This works perfectly except for 1 small detail (that does mess up my result): it appends a "+" at the end of my external url once redirected. The url in notebookmodel.Url is right, but once it passed through the Redirect it appends a "+" symbol at the end. Anything I'm doing wrong or can do to fix this?

1 Answer 1

1

I suspect that you have a whitespace at the end of the notebookmodel.Url property. Spaces are converted to + when url encoded. You could Trim it.

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

Comments

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.